Documentation ¶
Overview ¶
Package telemetry implements functionality to collect, aggregate, convert and export telemetry data in OpenTelemetry Protocol (OTLP) format.
The entrypoint is the OpenTelemetry (OTEL) go-metrics sink which: - Receives metric data. - Aggregates metric data using the OTEL Go Metrics SDK. - Exports metric data using a configurable OTEL exporter.
The package also provides an OTEL exporter implementation to be used within the sink, which: - Transforms metric data from the Metrics SDK OTEL representation to OTLP format. - Exports OTLP metric data to an external endpoint using a configurable client.
Index ¶
- func NewGaugeStore() *gaugeStore
- func NewOTELReader(client MetricsClient, endpointProvider EndpointProvider) otelsdk.Reader
- type ConfigProvider
- type EndpointProvider
- type MetricsClient
- type OTELSink
- func (o *OTELSink) AddSample(key []string, val float32)
- func (o *OTELSink) AddSampleWithLabels(key []string, val float32, labels []gometrics.Label)
- func (o *OTELSink) EmitKey(key []string, val float32)
- func (o *OTELSink) IncrCounter(key []string, val float32)
- func (o *OTELSink) IncrCounterWithLabels(key []string, val float32, labels []gometrics.Label)
- func (o *OTELSink) SetGauge(key []string, val float32)
- func (o *OTELSink) SetGaugeWithLabels(key []string, val float32, labels []gometrics.Label)
- type OTELSinkOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGaugeStore ¶
func NewGaugeStore() *gaugeStore
NewGaugeStore returns an initialized empty gaugeStore.
func NewOTELReader ¶
func NewOTELReader(client MetricsClient, endpointProvider EndpointProvider) otelsdk.Reader
NewOTELReader returns a configured OTEL PeriodicReader to export metrics every X seconds. It configures the reader with a custom OTELExporter with a MetricsClient to transform and export metrics in OTLP format to an external url.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface { // GetLabels should return a set of OTEL attributes added by default all metrics. GetLabels() map[string]string // GetFilters should return filtesr that are required to enable metric processing. // Filters act as an allowlist to collect only the required metrics. GetFilters() *regexp.Regexp }
ConfigProvider is required to provide custom metrics processing.
type EndpointProvider ¶
EndpointProvider provides the endpoint where metrics are exported to by the OTELExporter. EndpointProvider exposes the GetEndpoint() interface method to fetch the endpoint. This abstraction layer offers flexibility, in particular for dynamic configuration or changes to the endpoint.
type MetricsClient ¶
type MetricsClient interface {
ExportMetrics(ctx context.Context, protoMetrics *metricpb.ResourceMetrics, endpoint string) error
}
MetricsClient exports Consul metrics in OTLP format to the desired endpoint.
type OTELSink ¶
type OTELSink struct {
// contains filtered or unexported fields
}
OTELSink captures and aggregates telemetry data as per the OpenTelemetry (OTEL) specification. Metric data is exported in OpenTelemetry Protocol (OTLP) wire format. This should be used as a Go Metrics backend, as it implements the MetricsSink interface.
func NewOTELSink ¶
func NewOTELSink(ctx context.Context, opts *OTELSinkOpts) (*OTELSink, error)
NewOTELSink returns a sink which fits the Go Metrics MetricsSink interface. It sets up a MeterProvider and Meter, key pieces of the OTEL Metrics SDK which enable us to create OTEL Instruments to record measurements.
func (*OTELSink) AddSampleWithLabels ¶
AddSampleWithLabels emits a Consul sample metric that gets registed by an OpenTelemetry Histogram instrument.
func (*OTELSink) IncrCounter ¶
IncrCounter emits a Consul counter metric.
func (*OTELSink) IncrCounterWithLabels ¶
IncrCounterWithLabels emits a Consul counter metric that gets registed by an OpenTelemetry Histogram instrument.
type OTELSinkOpts ¶
type OTELSinkOpts struct { Reader otelsdk.Reader ConfigProvider ConfigProvider }
OTELSinkOpts is used to provide configuration when initializing an OTELSink using NewOTELSink.