convert

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: 24 Imported by: 0

Documentation

Overview

Package convert implements conversion utilities to convert between OpenTelemetry Collector data and Prometheus data.

It follows the OpenTelemetry Metrics Data Model for implementing the conversion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Converter

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

Converter implements consumer.Metrics and converts received metrics into Prometheus-compatible metrics.

func New

func New(l log.Logger, next storage.Appendable, opts Options) *Converter

New returns a new Converter. Converted metrics are passed to the provided storage.Appendable implementation.

func (*Converter) Capabilities

func (conv *Converter) Capabilities() consumer.Capabilities

Capabilities implements consumer.Metrics.

func (*Converter) ConsumeMetrics

func (conv *Converter) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error

ConsumeMetrics converts the provided OpenTelemetry Collector-formatted metrics into Prometheus-compatible metrics. Each call to ConsumeMetrics requests a storage.Appender and will commit generated metrics to it at the end of the call.

Metrics are tracked in memory over time. Call *Converter.GC to clean up stale metrics.

func (*Converter) FlushMetadata

func (conv *Converter) FlushMetadata()

FlushMetadata empties out the metadata cache, forcing metadata to get rewritten.

func (*Converter) GC

func (conv *Converter) GC(staleTime time.Duration)

GC cleans up stale metrics which have not been updated in the time specified by staleTime.

func (*Converter) UpdateOptions

func (conv *Converter) UpdateOptions(opts Options)

UpdateOptions updates the options for the Converter.

type Options

type Options struct {
	// IncludeTargetInfo includes the target_info metric.
	IncludeTargetInfo bool
	// IncludeScopeInfo includes the otel_scope_info metric and adds
	// otel_scope_name and otel_scope_version labels to data points.
	IncludeScopeInfo bool
	// IncludeScopeLabels includes the otel_scope_name and otel_scope_version
	// labels from the scope in the metrics.
	IncludeScopeLabels bool
	// AddMetricSuffixes controls whether suffixes are added to metric names. Defaults to true.
	AddMetricSuffixes bool
	// ResourceToTelemetryConversion controls whether to convert resource attributes to Prometheus-compatible datapoint attributes
	ResourceToTelemetryConversion bool
}

Options configure a Converter.

Jump to

Keyboard shortcuts

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