package reducer
import "go.opentelemetry.io/otel/sdk/metric/processor/reducer"
Package reducer implements a metrics Processor component to reduce attributes.
This package is currently in a pre-GA phase. Backwards incompatible changes may be introduced in subsequent minor version releases as we work to track the evolving OpenTelemetry specification and user feedback.
The metrics Processor component this package implements applies an attribute.Filter to each processed export.Accumulation to remove attributes before passing the result to another Processor. This Processor can be used to reduce inherent dimensionality in the data, as a way to control the cost of collecting high cardinality metric data.
For example, to compose a push controller with a reducer and a basic metric processor:
type someFilter struct{ // configuration for this filter // ... }
func (someFilter) AttributeFilterFor(_ *sdkapi.Descriptor) attribute.Filter { return func(attr kv.KeyValue) bool { // return true to keep this attr, false to drop this attr. // ... } }
func setupMetrics(exporter export.Exporter) (stop func()) { basicProcessorFactory := basic.NewFactory( simple.NewWithHistogramDistribution(), exporter, ) reducerProcessor := reducer.NewFactory(someFilter{...}, basicProcessorFactory) controller := controller.New( reducerProcessor, exporter, opts..., ) controller.Start() global.SetMeterProvider(controller.Provider()) return controller.Stop
Index ¶
Types ¶
type AttributeFilterSelector ¶
type AttributeFilterSelector interface { AttributeFilterFor(descriptor *sdkapi.Descriptor) attribute.Filter }
AttributeFilterSelector selects an attribute filter based on the instrument described by the descriptor.
type Processor ¶
type Processor struct { export.Checkpointer // contains filtered or unexported fields }
Processor implements "dimensionality reduction" by filtering keys from export attribute sets.
func New ¶
func New(filterSelector AttributeFilterSelector, ckpter export.Checkpointer) *Processor
New returns a dimensionality-reducing Processor that passes data to the next stage in an export pipeline.
func (*Processor) Process ¶
func (p *Processor) Process(accum export.Accumulation) error
Process implements export.Processor.
Source Files ¶
doc.go reducer.go
- Version
- v0.31.0
- Published
- Jul 8, 2022
- Platform
- js/wasm
- Imports
- 3 packages
- Last checked
- 8 hours ago –
Tools for package owners.