translator

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 25 Imported by: 1

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 added in v0.42.0

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 Dimensions added in v0.35.0

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 added in v0.35.0

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

AddTags to metrics dimensions.

func (*Dimensions) Host added in v0.35.0

func (d *Dimensions) Host() string

Host of the metric (may be empty).

func (*Dimensions) Name added in v0.35.0

func (d *Dimensions) Name() string

Name of the metric.

func (*Dimensions) OriginID added in v0.35.0

func (d *Dimensions) OriginID() string

OriginID of the metric (may be empty).

func (*Dimensions) String added in v0.35.0

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 added in v0.35.0

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

Tags of the metric (read-only).

func (*Dimensions) WithAttributeMap added in v0.35.0

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

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

func (*Dimensions) WithSuffix added in v0.35.0

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 MetricDataType

type MetricDataType int

MetricDataType is a timeseries-style metric type.

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

func (MetricDataType) MarshalText added in v0.42.0

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

MarshalText implements encoding.TextMarshaler.

func (*MetricDataType) UnmarshalText added in v0.42.0

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

UnmarshalText implements encoding.TextUnmarshaler.

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 Option

type Option func(*translatorConfig) error

Option is a translator creation option.

func WithCountSumMetrics

func WithCountSumMetrics() Option

WithCountSumMetrics exports .count and .sum histogram metrics.

func WithDeltaTTL

func WithDeltaTTL(deltaTTL int64) Option

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

func WithFallbackSourceProvider added in v0.38.0

func WithFallbackSourceProvider(provider source.Provider) Option

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

func WithHistogramMode

func WithHistogramMode(mode HistogramMode) Option

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

func WithInstrumentationLibraryMetadataAsTags added in v0.33.0

func WithInstrumentationLibraryMetadataAsTags() Option

WithInstrumentationLibraryMetadataAsTags sets instrumentation library metadata as tags.

func WithInstrumentationScopeMetadataAsTags added in v0.38.0

func WithInstrumentationScopeMetadataAsTags() Option

WithInstrumentationScopeMetadataAsTags sets instrumentation scope metadata as tags.

func WithNumberMode

func WithNumberMode(mode NumberMode) Option

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

func WithPreviewHostnameFromAttributes added in v0.38.0

func WithPreviewHostnameFromAttributes() Option

WithPreviewHostnameFromAttributes enables the preview hostname algorithm.

func WithQuantiles

func WithQuantiles() Option

WithQuantiles enables quantiles exporting for summary metrics.

func WithResourceAttributesAsTags

func WithResourceAttributesAsTags() Option

WithResourceAttributesAsTags sets resource attributes as tags.

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 added in v0.35.0

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 MetricDataType,
		timestamp uint64,
		value float64,
	)
}

TimeSeriesConsumer is timeseries consumer.

type Translator

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

Translator is a metrics translator.

func New

func New(logger *zap.Logger, options ...Option) (*Translator, error)

New creates a new translator with given options.

func (*Translator) MapMetrics

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

MapMetrics maps OTLP metrics into the DataDog format

func (*Translator) StatsPayloadToMetrics added in v0.42.0

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

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

Jump to

Keyboard shortcuts

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