package reducer
import "go.opentelemetry.io/otel/sdk/metric/processor/reducer"
Package reducer implements a metrics Processor component that applies a `label.Filter` to each processed `export.Accumulation` to remove labels 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) LabelFilterFor(_ *metric.Descriptor) label.Filter { return func(label kv.KeyValue) bool { // return true to keep this label, false to drop this label // ... } }
func setupMetrics(exporter export.Exporter) (stop func()) { basicProcessor := basic.New( simple.NewWithExactDistribution(), exporter, ) reducerProcessor := reducer.New(someFilter{...}, basicProcessor) pusher := push.New( reducerProcessor, exporter, pushOpts..., ) pusher.Start() global.SetMeterProvider(pusher.Provider()) return pusher.Stop
Index ¶
Types ¶
type LabelFilterSelector ¶
type LabelFilterSelector interface { LabelFilterFor(*metric.Descriptor) label.Filter }
LabelFilterSelector is the interface used to configure a specific Filter to an instrument.
type Processor ¶
type Processor struct { export.Checkpointer // contains filtered or unexported fields }
Processor implements "dimensionality reduction" by filtering keys from export label sets.
func New ¶
func New(filterSelector LabelFilterSelector, 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.11.0
- Published
- Aug 25, 2020
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 4 minutes ago –
Tools for package owners.