Documentation ¶
Index ¶
- func AggregatorSelector() export.AggregatorSelector
- func MultiInstrumentationLibraryReader(records map[instrumentation.Library][]export.Record) export.InstrumentationLibraryReader
- func NewCheckpointer(p *Processor) export.Checkpointer
- func NewCheckpointerFactory(selector export.AggregatorSelector, encoder attribute.Encoder) export.CheckpointerFactory
- func OneInstrumentationLibraryReader(l instrumentation.Library, r export.Reader) export.InstrumentationLibraryReader
- type Exporter
- type Output
- func (o *Output) AddAccumulation(acc export.Accumulation) error
- func (o *Output) AddInstrumentationLibraryRecord(_ instrumentation.Library, rec export.Record) error
- func (o *Output) AddRecord(rec export.Record) error
- func (o *Output) AddRecordWithResource(rec export.Record, res *resource.Resource) error
- func (o *Output) ForEach(_ aggregation.TemporalitySelector, ff func(export.Record) error) error
- func (o *Output) Map() map[string]float64
- func (o *Output) Reset()
- type Processor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggregatorSelector ¶
func AggregatorSelector() export.AggregatorSelector
AggregatorSelector returns a policy that is consistent with the test descriptors above. I.e., it returns sum.New() for counter instruments and lastvalue.New() for lastValue instruments.
func MultiInstrumentationLibraryReader ¶ added in v0.24.0
func MultiInstrumentationLibraryReader(records map[instrumentation.Library][]export.Record) export.InstrumentationLibraryReader
MultiInstrumentationLibraryReader returns an InstrumentationLibraryReader for a group of records that came from multiple instrumentation libraries.
func NewCheckpointer ¶ added in v0.24.0
func NewCheckpointer(p *Processor) export.Checkpointer
NewCheckpointer returns a new Checkpointer for Processor p.
func NewCheckpointerFactory ¶ added in v0.24.0
func NewCheckpointerFactory(selector export.AggregatorSelector, encoder attribute.Encoder) export.CheckpointerFactory
NewCheckpointerFactory returns a new CheckpointerFactory for the selector and encoder pair.
func OneInstrumentationLibraryReader ¶ added in v0.24.0
func OneInstrumentationLibraryReader(l instrumentation.Library, r export.Reader) export.InstrumentationLibraryReader
OneInstrumentationLibraryReader returns an InstrumentationLibraryReader for a single instrumentation library.
Types ¶
type Exporter ¶
type Exporter struct { aggregation.TemporalitySelector // InjectErr supports returning conditional errors from // the Export() routine. This must be set before the // Exporter is first used. InjectErr func(export.Record) error // contains filtered or unexported fields }
Exporter is a testing implementation of export.Exporter that assembles its results as a map[string]float64.
func New ¶ added in v0.21.0
func New(selector aggregation.TemporalitySelector, encoder attribute.Encoder) *Exporter
New returns a new testing Exporter implementation. Verify exporter outputs using Values(), e.g.,:
require.EqualValues(t, map[string]float64{ "counter.sum/A=1,B=2/R=V": 100, }, exporter.Values())
Where in the example A=1,B=2 is the encoded attributes and R=V is the encoded resource value.
func (*Exporter) Export ¶
func (e *Exporter) Export(_ context.Context, res *resource.Resource, ckpt export.InstrumentationLibraryReader) error
Export records all the measurements aggregated in ckpt for res.
func (*Exporter) ExportCount ¶
ExportCount returns the number of times Export() has been called since the last Reset().
func (*Exporter) Reset ¶
func (e *Exporter) Reset()
Reset sets the exporter's output to the initial, empty state and resets the export count to zero.
type Output ¶
Output implements export.Reader.
func NewOutput ¶
NewOutput is a helper for testing an expected set of Accumulations (from an Accumulator) or an expected set of Records (from a Processor). If testing with an Accumulator, it may be simpler to use the test Processor in this package.
func (*Output) AddAccumulation ¶
func (o *Output) AddAccumulation(acc export.Accumulation) error
AddAccumulation adds a string representation of the exported metric data to a map for use in testing. The value taken from the accumulation is either the Sum() or the LastValue() of its Aggregator().Aggregation(), whichever is defined.
func (*Output) AddInstrumentationLibraryRecord ¶ added in v0.24.0
func (o *Output) AddInstrumentationLibraryRecord(_ instrumentation.Library, rec export.Record) error
AddRecordWithResource merges rec into this Output.
func (*Output) AddRecord ¶
AddRecord adds a string representation of the exported metric data to a map for use in testing. The value taken from the record is either the Sum() or the LastValue() of its Aggregation(), whichever is defined. Record timestamps are ignored.
func (*Output) AddRecordWithResource ¶ added in v0.23.0
AddRecordWithResource merges rec into this Output scoping it with res.
func (*Output) ForEach ¶
func (o *Output) ForEach(_ aggregation.TemporalitySelector, ff func(export.Record) error) error
ForEach implements export.Reader.
type Processor ¶
type Processor struct { export.AggregatorSelector // contains filtered or unexported fields }
Processor is a testing implementation of export.Processor that assembles its results as a map[string]float64.
func NewProcessor ¶
func NewProcessor(selector export.AggregatorSelector, encoder attribute.Encoder) *Processor
NewProcessor returns a new testing Processor implementation. Verify expected outputs using Values(), e.g.:
require.EqualValues(t, map[string]float64{ "counter.sum/A=1,B=2/R=V": 100, }, processor.Values())
Where in the example A=1,B=2 is the encoded attributes and R=V is the encoded resource value.
func (*Processor) Process ¶
func (p *Processor) Process(accum export.Accumulation) error
Process implements export.Processor.
func (*Processor) Reset ¶ added in v0.23.0
func (p *Processor) Reset()
Reset clears the state of this test processor.