telemetrytest

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package telemetrytest records what Trove's telemetry emits, for tests: a span recorder installed as the global tracer provider, and an observe.Recorder that remembers every measurement and checks it against the metric definitions in package observe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attr

func Attr(s sdktrace.ReadOnlySpan, key string) (string, bool)

Attr returns the value of the attribute key on s, formatted as a string, and whether s has it.

func Key

func Key(name string, labelValues ...string) string

Key is how Recorder files a series: the name, then the label values.

func Leaks

func Leaks(rec *tracetest.SpanRecorder, value string) []string

Leaks returns every place value appears in what the recorder saw: a span name, an attribute, an event name or attribute, or a status description. A test that feeds a key, a bucket or a hash through the code asserts this is empty.

func Named

Named returns the ended spans called name, in the order they ended.

func Spans

func Spans(t *testing.T) *tracetest.SpanRecorder

Spans installs a span recorder as the global tracer provider, and forge's default propagators (tracecontext and baggage) as the global propagator, for the rest of the test. The previous ones come back when the test ends.

func SpansWithEnds

func SpansWithEnds(t *testing.T) (rec *tracetest.SpanRecorder, ends <-chan string)

SpansWithEnds is Spans, and also reports the name of each span as it ends, so a test can wait with WaitEnded for a span another goroutine ends instead of sleeping.

func WaitEnded

func WaitEnded(t *testing.T, ends <-chan string, name string)

WaitEnded waits until a span called name ends, failing the test after ten seconds.

Types

type Recorder

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

Recorder is an observe.Recorder that keeps every measurement. It fails the test when a call names a metric observe does not declare, uses the wrong method for its kind, passes the wrong number of label values, or passes a value outside the documented set.

func NewRecorder

func NewRecorder(t testing.TB) *Recorder

NewRecorder returns an empty Recorder that reports misuse to t.

func (*Recorder) Add

func (r *Recorder) Add(name string, delta float64, labelValues ...string)

Add implements observe.Recorder.

func (*Recorder) Count

func (r *Recorder) Count(name string, labelValues ...string) int

Count returns how many values the histogram series observed.

func (*Recorder) Counter

func (r *Recorder) Counter(name string, labelValues ...string) float64

Counter returns the total added to the series.

func (*Recorder) Observe

func (r *Recorder) Observe(name string, value float64, labelValues ...string)

Observe implements observe.Recorder.

func (*Recorder) Series

func (r *Recorder) Series(name string) []string

Series returns the keys of every series recorded under name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL