spanmetrics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package spanmetrics provides an otelcol.connector.spanmetrics component.

Index

Constants

View Source
const (
	AggregationTemporalityCumulative = "CUMULATIVE"
	AggregationTemporalityDelta      = "DELTA"
)
View Source
const (
	MetricsUnitMilliseconds string = "ms"
	MetricsUnitSeconds      string = "s"
)

Variables

View Source
var DefaultArguments = Arguments{
	DimensionsCacheSize:      1000,
	AggregationTemporality:   AggregationTemporalityCumulative,
	MetricsFlushInterval:     15 * time.Second,
	ResourceMetricsCacheSize: 1000,
}

DefaultArguments holds default settings for Arguments.

View Source
var DefaultHistogramConfig = HistogramConfig{
	Unit:        MetricsUnitMilliseconds,
	Exponential: nil,
	Explicit:    nil,
}

Functions

func ConvertMetricUnit

func ConvertMetricUnit(unit string) (map[string]interface{}, error)

The unit is a private type in an internal Otel package, so we need to convert it to a map and then back to the internal type. ConvertMetricUnit matches the Unit type in this internal package: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.96.0/connector/spanmetricsconnector/internal/metrics/unit.go

func FromOTelAggregationTemporality

func FromOTelAggregationTemporality(temporality string) string

Types

type Arguments

type Arguments struct {
	// Dimensions defines the list of additional dimensions on top of the provided:
	// - service.name
	// - span.name
	// - span.kind
	// - status.code
	// The dimensions will be fetched from the span's attributes. Examples of some conventionally used attributes:
	// https://github.com/open-telemetry/opentelemetry-collector/blob/main/model/semconv/opentelemetry.go.
	Dimensions        []Dimension `alloy:"dimension,block,optional"`
	ExcludeDimensions []string    `alloy:"exclude_dimensions,attr,optional"`

	// DimensionsCacheSize defines the size of cache for storing Dimensions, which helps to avoid cache memory growing
	// indefinitely over the lifetime of the collector.
	DimensionsCacheSize int `alloy:"dimensions_cache_size,attr,optional"`

	// ResourceMetricsCacheSize defines the size of the cache holding metrics for a service. This is mostly relevant for
	// cumulative temporality to avoid memory leaks and correct metric timestamp resets.
	ResourceMetricsCacheSize int `alloy:"resource_metrics_cache_size,attr,optional"`

	// ResourceMetricsKeyAttributes filters the resource attributes used to create the resource metrics key hash.
	// This can be used to avoid situations where resource attributes may change across service restarts, causing
	// metric counters to break (and duplicate). A resource does not need to have all of the attributes. The list
	// must include enough attributes to properly identify unique resources or risk aggregating data from more
	// than one service and span.
	// e.g. ["service.name", "telemetry.sdk.language", "telemetry.sdk.name"]
	// See https://opentelemetry.io/docs/specs/semconv/resource/ for possible attributes.
	ResourceMetricsKeyAttributes []string `alloy:"resource_metrics_key_attributes,attr,optional"`

	AggregationTemporality string `alloy:"aggregation_temporality,attr,optional"`

	Histogram HistogramConfig `alloy:"histogram,block"`

	// MetricsEmitInterval is the time period between when metrics are flushed or emitted to the downstream components.
	MetricsFlushInterval time.Duration `alloy:"metrics_flush_interval,attr,optional"`

	// Namespace is the namespace of the metrics emitted by the connector.
	Namespace string `alloy:"namespace,attr,optional"`

	// Exemplars defines the configuration for exemplars.
	Exemplars ExemplarsConfig `alloy:"exemplars,block,optional"`

	// Events defines the configuration for events section of spans.
	Events EventsConfig `alloy:"events,block,optional"`

	// Output configures where to send processed data. Required.
	Output *otelcol.ConsumerArguments `alloy:"output,block"`
}

Arguments configures the otelcol.connector.spanmetrics component.

func (Arguments) ConnectorType

func (Arguments) ConnectorType() int

ConnectorType() int implements connector.Arguments.

func (Arguments) Convert

func (args Arguments) Convert() (otelcomponent.Config, error)

Convert implements connector.Arguments.

func (Arguments) Exporters

Exporters implements connector.Arguments.

func (Arguments) Extensions

func (args Arguments) Extensions() map[otelcomponent.ID]otelextension.Extension

Extensions implements connector.Arguments.

func (Arguments) NextConsumers

func (args Arguments) NextConsumers() *otelcol.ConsumerArguments

NextConsumers implements connector.Arguments.

func (*Arguments) SetToDefault

func (args *Arguments) SetToDefault()

SetToDefault implements syntax.Defaulter.

func (*Arguments) Validate

func (args *Arguments) Validate() error

Validate implements syntax.Validator.

type Dimension

type Dimension struct {
	Name    string  `alloy:"name,attr"`
	Default *string `alloy:"default,attr,optional"`
}

Dimension defines the dimension name and optional default value if the Dimension is missing from a span attribute.

func (Dimension) Convert

type EventsConfig

type EventsConfig struct {
	// Enabled is a flag to enable events.
	Enabled bool `alloy:"enabled,attr,optional"`
	// Dimensions defines the list of dimensions to add to the events metric.
	Dimensions []Dimension `alloy:"dimension,block,optional"`
}

func (EventsConfig) Convert

type ExemplarsConfig

type ExemplarsConfig struct {
	Enabled         bool `alloy:"enabled,attr,optional"`
	MaxPerDataPoint *int `alloy:"max_per_data_point,attr,optional"`
}

func (ExemplarsConfig) Convert

type ExplicitHistogramConfig

type ExplicitHistogramConfig struct {
	// Buckets is the list of durations representing explicit histogram buckets.
	Buckets []time.Duration `alloy:"buckets,attr,optional"`
}

func (ExplicitHistogramConfig) Convert

func (*ExplicitHistogramConfig) SetToDefault

func (hc *ExplicitHistogramConfig) SetToDefault()

type ExponentialHistogramConfig

type ExponentialHistogramConfig struct {
	MaxSize int32 `alloy:"max_size,attr,optional"`
}

func (ExponentialHistogramConfig) Convert

func (*ExponentialHistogramConfig) SetToDefault

func (ehc *ExponentialHistogramConfig) SetToDefault()

SetToDefault implements syntax.Defaulter.

func (*ExponentialHistogramConfig) Validate

func (ehc *ExponentialHistogramConfig) Validate() error

Validate implements syntax.Validator.

type HistogramConfig

type HistogramConfig struct {
	Disable     bool                        `alloy:"disable,attr,optional"`
	Unit        string                      `alloy:"unit,attr,optional"`
	Exponential *ExponentialHistogramConfig `alloy:"exponential,block,optional"`
	Explicit    *ExplicitHistogramConfig    `alloy:"explicit,block,optional"`
}

func (HistogramConfig) Convert

func (*HistogramConfig) SetToDefault

func (hc *HistogramConfig) SetToDefault()

func (*HistogramConfig) Validate

func (hc *HistogramConfig) Validate() error

Jump to

Keyboard shortcuts

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