metricgo.opentelemetry.io/otel/metric/metrictest Index | Files

package metrictest

import "go.opentelemetry.io/otel/metric/metrictest"

Index

Functions

func LabelsToMap

func LabelsToMap(kvs ...attribute.KeyValue) map[attribute.Key]attribute.Value

LabelsToMap converts label set to keyValue map, to be easily used in tests

func ResolveNumberByKind

func ResolveNumberByKind(t *testing.T, kind number.Kind, value float64) number.Number

ResolveNumberByKind takes defined metric descriptor creates a concrete typed metric number

Types

type Async

type Async struct {
	Instrument
	// contains filtered or unexported fields
}

func (*Async) Implementation

func (a *Async) Implementation() interface{}

type Batch

type Batch struct {
	// Measurement needs to be aligned for 64-bit atomic operations.
	Measurements []Measurement
	Ctx          context.Context
	Labels       []attribute.KeyValue
	LibraryName  string
}

type Handle

type Handle struct {
	Instrument *Sync
	Labels     []attribute.KeyValue
}

func (*Handle) RecordOne

func (h *Handle) RecordOne(ctx context.Context, number number.Number)

func (*Handle) Unbind

func (h *Handle) Unbind()

type Instrument

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

func (Instrument) Descriptor

func (i Instrument) Descriptor() metric.Descriptor

type Measured

type Measured struct {
	Name                   string
	InstrumentationName    string
	InstrumentationVersion string
	Labels                 map[attribute.Key]attribute.Value
	Number                 number.Number
}

Measured is the helper struct which provides flat representation of recorded measurements to simplify testing

func AsStructs

func AsStructs(batches []Batch) []Measured

AsStructs converts recorded batches to array of flat, readable Measured helper structures

type Measurement

type Measurement struct {
	// Number needs to be aligned for 64-bit atomic operations.
	Number     number.Number
	Instrument metric.InstrumentImpl
}

type MeterImpl

type MeterImpl struct {
	MeasurementBatches []Batch
	// contains filtered or unexported fields
}

MeterImpl is an OpenTelemetry Meter implementation used for testing.

func NewMeter

func NewMeter() (*MeterImpl, metric.Meter)

func NewMeterProvider

func NewMeterProvider() (*MeterImpl, metric.MeterProvider)

func (*MeterImpl) CollectAsync

func (m *MeterImpl) CollectAsync(labels []attribute.KeyValue, obs ...metric.Observation)

func (*MeterImpl) NewAsyncInstrument

func (m *MeterImpl) NewAsyncInstrument(descriptor metric.Descriptor, runner metric.AsyncRunner) (metric.AsyncImpl, error)

func (*MeterImpl) NewSyncInstrument

func (m *MeterImpl) NewSyncInstrument(descriptor metric.Descriptor) (metric.SyncImpl, error)

func (*MeterImpl) RecordBatch

func (m *MeterImpl) RecordBatch(ctx context.Context, labels []attribute.KeyValue, measurements ...metric.Measurement)

func (*MeterImpl) RunAsyncInstruments

func (m *MeterImpl) RunAsyncInstruments()

type Sync

type Sync struct {
	Instrument
}

func (*Sync) Bind

func (s *Sync) Bind(labels []attribute.KeyValue) metric.BoundSyncImpl

func (*Sync) Implementation

func (s *Sync) Implementation() interface{}

func (*Sync) RecordOne

func (s *Sync) RecordOne(ctx context.Context, number number.Number, labels []attribute.KeyValue)

Source Files

meter.go

Version
v0.22.0
Published
Jul 19, 2021
Platform
darwin/amd64
Imports
8 packages
Last checked
14 minutes ago

Tools for package owners.