telemetrytest

package
v1.8.2 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetrytest records what vault's telemetry emits so tests can assert on it: spans through a tracetest.SpanRecorder installed as the global tracer provider, and metrics through a go-utils sink that remembers every series it handed out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNoLeak

func AssertNoLeak(t testing.TB, rec *tracetest.SpanRecorder, needles ...string)

AssertNoLeak fails the test if any needle appears anywhere on an ended span: its name, an attribute, an event or event attribute, its status description, or a link's attributes.

func Attr

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

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

func Named

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

func SeriesKey

func SeriesKey(name string, labels map[string]string) string

SeriesKey renders name and labels the way the sink keys a series: name{k1="v1",k2="v2"} with the keys sorted.

func Spans

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

Spans installs a span recorder as the global tracer provider for the rest of the test and puts the old provider back in cleanup.

Types

type Sink

type Sink struct {
	*gometrics.MockMetrics
	// contains filtered or unexported fields
}

Sink is a go-utils metrics sink that keeps every counter and histogram it hands out, keyed by name and labels.

func NewSink

func NewSink() *Sink

NewSink returns an empty sink.

func (*Sink) AssertNoLeak

func (s *Sink) AssertNoLeak(t testing.TB, needles ...string)

AssertNoLeak fails the test if any needle appears in a metric name, label key or label value the sink handed out.

func (*Sink) Count

func (s *Sink) Count(name string, labels map[string]string) float64

Count returns a counter's value, 0 when the series was never created.

func (*Sink) LabelSets

func (s *Sink) LabelSets(name string) []map[string]string

LabelSets returns every label set handed out under name.

func (*Sink) Names

func (s *Sink) Names() []string

Names returns every metric name the sink handed a series out for.

func (*Sink) Observations

func (s *Sink) Observations(name string, labels map[string]string) uint64

Observations returns how many values a histogram series recorded.

Jump to

Keyboard shortcuts

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