metrics

package module
v0.0.0-...-0a2ab44 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const UnsetHostnamePlaceholder = "__unset__"

UnsetHostnamePlaceholder is the string used as a hostname when the hostname can not be extracted from span attributes by the processor. Upon decoding the metrics, the Translator will use its configured fallback SourceProvider to replace it with the correct hostname.

This isn't the most ideal approach to the problem, but provides the better user experience by avoiding the need to duplicate the "exporter::datadog::hostname" configuration field as "processor::datadog::hostname". The hostname can also not be left empty in case of failure to obtain it, because empty has special meaning. An empty hostname means that we are in a Lambda environment. Thus, we must use a placeholder.

Variables

This section is empty.

Functions

This section is empty.

Types

type APMStatsConsumer

type APMStatsConsumer interface {
	// ConsumeAPMStats consumes the given StatsPayload.
	ConsumeAPMStats(*pb.ClientStatsPayload)
}

APMStatsConsumer implementations are able to consume APM Stats generated by a Translator.

type Consumer

type Consumer interface {
	TimeSeriesConsumer
	SketchConsumer
	APMStatsConsumer
}

Consumer is a metrics consumer.

type DataType

type DataType int

DataType is a timeseries-style metric type.

const (
	// Gauge is the Datadog Gauge metric type.
	Gauge DataType = iota
	// Count is the Datadog Count metric type.
	Count
)

func (DataType) MarshalText

func (t DataType) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*DataType) UnmarshalText

func (t *DataType) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Dimensions

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

Dimensions of a metric that identify a timeseries uniquely. This is similar to the concept of 'context' in DogStatsD/check metrics. NOTE: Keep this in sync with the TestDimensions struct.

func (*Dimensions) AddTags

func (d *Dimensions) AddTags(tags ...string) *Dimensions

AddTags to metrics dimensions.

func (*Dimensions) Host

func (d *Dimensions) Host() string

Host of the metric (may be empty).

func (*Dimensions) Name

func (d *Dimensions) Name() string

Name of the metric.

func (*Dimensions) OriginID

func (d *Dimensions) OriginID() string

OriginID of the metric (may be empty).

func (*Dimensions) String

func (d *Dimensions) String() string

String maps dimensions to a string to use as an identifier. The tags order does not matter.

func (*Dimensions) Tags

func (d *Dimensions) Tags() []string

Tags of the metric (read-only).

func (*Dimensions) WithAttributeMap

func (d *Dimensions) WithAttributeMap(labels pcommon.Map) *Dimensions

WithAttributeMap creates a new metricDimensions struct with additional tags from attributes.

func (*Dimensions) WithSuffix

func (d *Dimensions) WithSuffix(suffix string) *Dimensions

WithSuffix creates a new dimensions struct with an extra name suffix.

type HistogramMode

type HistogramMode string

HistogramMode is an export mode for OTLP Histogram metrics.

const (
	// HistogramModeNoBuckets disables bucket export.
	HistogramModeNoBuckets HistogramMode = "nobuckets"
	// HistogramModeCounters exports buckets as Datadog counts.
	HistogramModeCounters HistogramMode = "counters"
	// HistogramModeDistributions exports buckets as Datadog distributions.
	HistogramModeDistributions HistogramMode = "distributions"
)

type HostConsumer

type HostConsumer interface {
	// ConsumeHost consumes a hostname.
	ConsumeHost(host string)
}

HostConsumer is a hostname consumer. It is an optional interface that can be implemented by a Consumer.

type Metadata

type Metadata struct {
	// Languages specifies a list of languages for which runtime metrics were found.
	Languages []string
}

Metadata specifies information about the outcome of the MapMetrics call.

type NumberMode

type NumberMode string

NumberMode is an export mode for OTLP Number metrics.

const (
	// NumberModeCumulativeToDelta calculates delta for
	// cumulative monotonic metrics in the client side and reports
	// them as Datadog counts.
	NumberModeCumulativeToDelta NumberMode = "cumulative_to_delta"

	// NumberModeRawValue reports the raw value for cumulative monotonic
	// metrics as a Datadog gauge.
	NumberModeRawValue NumberMode = "raw_value"
)

type SketchConsumer

type SketchConsumer interface {
	// ConsumeSketch consumes a pkg/quantile-style sketch.
	ConsumeSketch(
		ctx context.Context,
		dimensions *Dimensions,
		timestamp uint64,
		sketch *quantile.Sketch,
	)
}

SketchConsumer is a pkg/quantile sketch consumer.

type TagsConsumer

type TagsConsumer interface {
	// ConsumeTag consumes a tag
	ConsumeTag(tag string)
}

TagsConsumer is a tags consumer. It is an optional interface that can be implemented by a Consumer. Consumed tags are used for running metrics, and should represent some resource running a Collector (e.g. Fargate task).

type TimeSeriesConsumer

type TimeSeriesConsumer interface {
	// ConsumeTimeSeries consumes a timeseries-style metric.
	ConsumeTimeSeries(
		ctx context.Context,
		dimensions *Dimensions,
		typ DataType,
		timestamp uint64,
		value float64,
	)
}

TimeSeriesConsumer is timeseries consumer.

type Translator

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

Translator is a metrics translator.

func NewTranslator

func NewTranslator(logger *zap.Logger, options ...TranslatorOption) (*Translator, error)

NewTranslator creates a new translator with given options.

func (*Translator) MapMetrics

func (t *Translator) MapMetrics(ctx context.Context, md pmetric.Metrics, consumer Consumer) (Metadata, error)

MapMetrics maps OTLP metrics into the DataDog format

func (*Translator) StatsPayloadToMetrics

func (t *Translator) StatsPayloadToMetrics(sp *pb.StatsPayload) pmetric.Metrics

StatsPayloadToMetrics converts an APM Stats Payload to a set of OTLP Metrics.

type TranslatorOption

type TranslatorOption func(*translatorConfig) error

TranslatorOption is a translator creation option.

func WithCountSumMetrics

func WithCountSumMetrics() TranslatorOption

WithCountSumMetrics exports .count and .sum histogram metrics. Deprecated: Use WithHistogramAggregations instead.

func WithDeltaTTL

func WithDeltaTTL(deltaTTL int64) TranslatorOption

WithDeltaTTL sets the delta TTL for cumulative metrics datapoints. By default, 3600 seconds are used.

func WithFallbackSourceProvider

func WithFallbackSourceProvider(provider source.Provider) TranslatorOption

WithFallbackSourceProvider sets the fallback source provider. By default, an empty hostname is used as a fallback.

func WithHistogramAggregations

func WithHistogramAggregations() TranslatorOption

WithHistogramAggregations exports .count, .sum, .min and .max histogram metrics when available.

func WithHistogramMode

func WithHistogramMode(mode HistogramMode) TranslatorOption

WithHistogramMode sets the histograms mode. The default mode is HistogramModeOff.

func WithInstrumentationLibraryMetadataAsTags

func WithInstrumentationLibraryMetadataAsTags() TranslatorOption

WithInstrumentationLibraryMetadataAsTags sets instrumentation library metadata as tags.

func WithInstrumentationScopeMetadataAsTags

func WithInstrumentationScopeMetadataAsTags() TranslatorOption

WithInstrumentationScopeMetadataAsTags sets instrumentation scope metadata as tags.

func WithNumberMode

func WithNumberMode(mode NumberMode) TranslatorOption

WithNumberMode sets the number mode. The default mode is NumberModeCumulativeToDelta.

func WithQuantiles

func WithQuantiles() TranslatorOption

WithQuantiles enables quantiles exporting for summary metrics.

func WithResourceAttributesAsTags

func WithResourceAttributesAsTags() TranslatorOption

WithResourceAttributesAsTags sets resource attributes as tags.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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