metadata

package
v0.96.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TracesStability  = component.StabilityLevelBeta
	LogsStability    = component.StabilityLevelDevelopment
	MetricsStability = component.StabilityLevelStable
)

Variables

View Source
var MapAttributeEnumAttr = map[string]AttributeEnumAttr{
	"red":   AttributeEnumAttrRed,
	"green": AttributeEnumAttrGreen,
	"blue":  AttributeEnumAttrBlue,
}

MapAttributeEnumAttr is a helper map of string to AttributeEnumAttr attribute value.

View Source
var (
	Type = component.MustNewType("file")
)

Functions

func Meter

func Meter(settings component.TelemetrySettings) metric.Meter

func Tracer

func Tracer(settings component.TelemetrySettings) trace.Tracer

func WithStartTime

func WithStartTime(startTime pcommon.Timestamp) metricBuilderOption

WithStartTime sets startTime on the metrics builder.

Types

type AttributeEnumAttr

type AttributeEnumAttr int

AttributeEnumAttr specifies the a value enum_attr attribute.

const (
	AttributeEnumAttrRed AttributeEnumAttr
	AttributeEnumAttrGreen
	AttributeEnumAttrBlue
)

func (AttributeEnumAttr) String

func (av AttributeEnumAttr) String() string

String returns the string representation of the AttributeEnumAttr.

type MetricConfig

type MetricConfig struct {
	Enabled bool `mapstructure:"enabled"`
	// contains filtered or unexported fields
}

MetricConfig provides common config for a particular metric.

func (*MetricConfig) Unmarshal

func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error

type MetricsBuilder

type MetricsBuilder struct {
	// contains filtered or unexported fields
}

MetricsBuilder provides an interface for scrapers to report metrics while taking care of all the transformations required to produce metric representation defined in metadata and user config.

func NewMetricsBuilder

func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSettings, options ...metricBuilderOption) *MetricsBuilder

func (*MetricsBuilder) Emit

Emit returns all the metrics accumulated by the metrics builder and updates the internal state to be ready for recording another set of metrics. This function will be responsible for applying all the transformations required to produce metric representation defined in metadata and user config, e.g. delta or cumulative.

func (*MetricsBuilder) EmitForResource

func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption)

EmitForResource saves all the generated metrics under a new resource and updates the internal state to be ready for recording another set of data points as part of another resource. This function can be helpful when one scraper needs to emit metrics from several resources. Otherwise calling this function is not required, just `Emit` function can be called instead. Resource attributes should be provided as ResourceMetricsOption arguments.

func (*MetricsBuilder) NewResourceBuilder

func (mb *MetricsBuilder) NewResourceBuilder() *ResourceBuilder

NewResourceBuilder returns a new resource builder that should be used to build a resource associated with for the emitted metrics.

func (*MetricsBuilder) RecordDefaultMetricDataPoint

func (mb *MetricsBuilder) RecordDefaultMetricDataPoint(ts pcommon.Timestamp, val int64, stringAttrAttributeValue string, overriddenIntAttrAttributeValue int64, enumAttrAttributeValue AttributeEnumAttr, sliceAttrAttributeValue []any, mapAttrAttributeValue map[string]any)

RecordDefaultMetricDataPoint adds a data point to default.metric metric.

func (*MetricsBuilder) RecordDefaultMetricToBeRemovedDataPoint

func (mb *MetricsBuilder) RecordDefaultMetricToBeRemovedDataPoint(ts pcommon.Timestamp, val float64)

RecordDefaultMetricToBeRemovedDataPoint adds a data point to default.metric.to_be_removed metric.

func (*MetricsBuilder) RecordOptionalMetricDataPoint

func (mb *MetricsBuilder) RecordOptionalMetricDataPoint(ts pcommon.Timestamp, val float64, stringAttrAttributeValue string, booleanAttrAttributeValue bool)

RecordOptionalMetricDataPoint adds a data point to optional.metric metric.

func (*MetricsBuilder) RecordOptionalMetricEmptyUnitDataPoint

func (mb *MetricsBuilder) RecordOptionalMetricEmptyUnitDataPoint(ts pcommon.Timestamp, val float64, stringAttrAttributeValue string, booleanAttrAttributeValue bool)

RecordOptionalMetricEmptyUnitDataPoint adds a data point to optional.metric.empty_unit metric.

func (*MetricsBuilder) Reset

func (mb *MetricsBuilder) Reset(options ...metricBuilderOption)

Reset resets metrics builder to its initial state. It should be used when external metrics source is restarted, and metrics builder should update its startTime and reset it's internal state accordingly.

type MetricsBuilderConfig

type MetricsBuilderConfig struct {
	Metrics            MetricsConfig            `mapstructure:"metrics"`
	ResourceAttributes ResourceAttributesConfig `mapstructure:"resource_attributes"`
}

MetricsBuilderConfig is a configuration for file metrics builder.

func DefaultMetricsBuilderConfig

func DefaultMetricsBuilderConfig() MetricsBuilderConfig

type MetricsConfig

type MetricsConfig struct {
	DefaultMetric            MetricConfig `mapstructure:"default.metric"`
	DefaultMetricToBeRemoved MetricConfig `mapstructure:"default.metric.to_be_removed"`
	OptionalMetric           MetricConfig `mapstructure:"optional.metric"`
	OptionalMetricEmptyUnit  MetricConfig `mapstructure:"optional.metric.empty_unit"`
}

MetricsConfig provides config for file metrics.

func DefaultMetricsConfig

func DefaultMetricsConfig() MetricsConfig

type ResourceAttributeConfig

type ResourceAttributeConfig struct {
	Enabled bool `mapstructure:"enabled"`
	// contains filtered or unexported fields
}

ResourceAttributeConfig provides common config for a particular resource attribute.

func (*ResourceAttributeConfig) Unmarshal

func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error

type ResourceAttributesConfig

type ResourceAttributesConfig struct {
	MapResourceAttr                  ResourceAttributeConfig `mapstructure:"map.resource.attr"`
	OptionalResourceAttr             ResourceAttributeConfig `mapstructure:"optional.resource.attr"`
	SliceResourceAttr                ResourceAttributeConfig `mapstructure:"slice.resource.attr"`
	StringEnumResourceAttr           ResourceAttributeConfig `mapstructure:"string.enum.resource.attr"`
	StringResourceAttr               ResourceAttributeConfig `mapstructure:"string.resource.attr"`
	StringResourceAttrDisableWarning ResourceAttributeConfig `mapstructure:"string.resource.attr_disable_warning"`
	StringResourceAttrRemoveWarning  ResourceAttributeConfig `mapstructure:"string.resource.attr_remove_warning"`
	StringResourceAttrToBeRemoved    ResourceAttributeConfig `mapstructure:"string.resource.attr_to_be_removed"`
}

ResourceAttributesConfig provides config for file resource attributes.

func DefaultResourceAttributesConfig

func DefaultResourceAttributesConfig() ResourceAttributesConfig

type ResourceBuilder

type ResourceBuilder struct {
	// contains filtered or unexported fields
}

ResourceBuilder is a helper struct to build resources predefined in metadata.yaml. The ResourceBuilder is not thread-safe and must not to be used in multiple goroutines.

func NewResourceBuilder

func NewResourceBuilder(rac ResourceAttributesConfig) *ResourceBuilder

NewResourceBuilder creates a new ResourceBuilder. This method should be called on the start of the application.

func (*ResourceBuilder) Emit

func (rb *ResourceBuilder) Emit() pcommon.Resource

Emit returns the built resource and resets the internal builder state.

func (*ResourceBuilder) SetMapResourceAttr

func (rb *ResourceBuilder) SetMapResourceAttr(val map[string]any)

SetMapResourceAttr sets provided value as "map.resource.attr" attribute.

func (*ResourceBuilder) SetOptionalResourceAttr

func (rb *ResourceBuilder) SetOptionalResourceAttr(val string)

SetOptionalResourceAttr sets provided value as "optional.resource.attr" attribute.

func (*ResourceBuilder) SetSliceResourceAttr

func (rb *ResourceBuilder) SetSliceResourceAttr(val []any)

SetSliceResourceAttr sets provided value as "slice.resource.attr" attribute.

func (*ResourceBuilder) SetStringEnumResourceAttrOne

func (rb *ResourceBuilder) SetStringEnumResourceAttrOne()

SetStringEnumResourceAttrOne sets "string.enum.resource.attr=one" attribute.

func (*ResourceBuilder) SetStringEnumResourceAttrTwo

func (rb *ResourceBuilder) SetStringEnumResourceAttrTwo()

SetStringEnumResourceAttrTwo sets "string.enum.resource.attr=two" attribute.

func (*ResourceBuilder) SetStringResourceAttr

func (rb *ResourceBuilder) SetStringResourceAttr(val string)

SetStringResourceAttr sets provided value as "string.resource.attr" attribute.

func (*ResourceBuilder) SetStringResourceAttrDisableWarning

func (rb *ResourceBuilder) SetStringResourceAttrDisableWarning(val string)

SetStringResourceAttrDisableWarning sets provided value as "string.resource.attr_disable_warning" attribute.

func (*ResourceBuilder) SetStringResourceAttrRemoveWarning

func (rb *ResourceBuilder) SetStringResourceAttrRemoveWarning(val string)

SetStringResourceAttrRemoveWarning sets provided value as "string.resource.attr_remove_warning" attribute.

func (*ResourceBuilder) SetStringResourceAttrToBeRemoved

func (rb *ResourceBuilder) SetStringResourceAttrToBeRemoved(val string)

SetStringResourceAttrToBeRemoved sets provided value as "string.resource.attr_to_be_removed" attribute.

type ResourceMetricsOption

type ResourceMetricsOption func(pmetric.ResourceMetrics)

ResourceMetricsOption applies changes to provided resource metrics.

func WithResource

func WithResource(res pcommon.Resource) ResourceMetricsOption

WithResource sets the provided resource on the emitted ResourceMetrics. It's recommended to use ResourceBuilder to create the resource.

func WithStartTimeOverride

func WithStartTimeOverride(start pcommon.Timestamp) ResourceMetricsOption

WithStartTimeOverride overrides start time for all the resource metrics data points. This option should be only used if different start time has to be set on metrics coming from different resources.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL