package test

import "go.opentelemetry.io/otel/sdk/metric/batcher/test"

Index

Variables

var (
	// LastValueADesc and LastValueBDesc group by "G"
	LastValueADesc = metric.NewDescriptor(
		"lastvalue.a", metric.ObserverKind, core.Int64NumberKind, metric.WithKeys(key.New("G")))
	LastValueBDesc = metric.NewDescriptor(
		"lastvalue.b", metric.ObserverKind, core.Int64NumberKind, metric.WithKeys(key.New("G")))
	// CounterADesc and CounterBDesc group by "C"
	CounterADesc = metric.NewDescriptor(
		"sum.a", metric.CounterKind, core.Int64NumberKind, metric.WithKeys(key.New("C")))
	CounterBDesc = metric.NewDescriptor(
		"sum.b", metric.CounterKind, core.Int64NumberKind, metric.WithKeys(key.New("C")))

	// SdkEncoder uses a non-standard encoder like K1~V1&K2~V2
	SdkEncoder = &Encoder{}
	// GroupEncoder uses the SDK default encoder
	GroupEncoder = export.NewDefaultLabelEncoder()

	// Labels1 has G=H and C=D
	Labels1 = makeLabels(SdkEncoder, key.String("G", "H"), key.String("C", "D"))
	// Labels2 has C=D and E=F
	Labels2 = makeLabels(SdkEncoder, key.String("C", "D"), key.String("E", "F"))
	// Labels3 is the empty set
	Labels3 = makeLabels(SdkEncoder)
)

Functions

func CounterAgg

func CounterAgg(desc *metric.Descriptor, v int64) export.Aggregator

CounterAgg returns a checkpointed counter aggregator w/ the specified descriptor and value.

func LastValueAgg

func LastValueAgg(desc *metric.Descriptor, v int64) export.Aggregator

LastValueAgg returns a checkpointed lastValue aggregator w/ the specified descriptor and value.

func NewAggregationSelector

func NewAggregationSelector() export.AggregationSelector

NewAggregationSelector 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 NewCounterRecord

func NewCounterRecord(desc *metric.Descriptor, labels export.Labels, value int64) export.Record

Convenience method for building a test exported counter record.

func NewLastValueRecord

func NewLastValueRecord(desc *metric.Descriptor, labels export.Labels, value int64) export.Record

Convenience method for building a test exported lastValue record.

Types

type Encoder

type Encoder struct{}

Encoder is an alternate label encoder to validate grouping logic.

func (Encoder) Encode

func (Encoder) Encode(iter export.LabelIterator) string

func (Encoder) ID

func (Encoder) ID() int64

type Output

type Output struct {
	Map map[string]float64
	// contains filtered or unexported fields
}

Output collects distinct metric/label set outputs.

func NewOutput

func NewOutput(labelEncoder export.LabelEncoder) Output

func (Output) AddTo

func (o Output) AddTo(rec export.Record) error

AddTo adds a name/label-encoding entry with the lastValue or counter value to the output map.

Source Files

test.go

Version
v0.4.0
Published
Mar 30, 2020
Platform
linux/amd64
Imports
10 packages
Last checked
7 minutes ago

Tools for package owners.