obstest

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package obstest holds the test doubles for Ctrl Plane's telemetry: a span recorder installed as the global tracer provider, a metrics sink that remembers every series by name and labels, and a check that sensitive values never reach a span.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAbsent

func AssertAbsent(t *testing.T, spans []sdktrace.ReadOnlySpan, values ...string)

AssertAbsent fails when any of values shows up in a span's name, status description, attributes, or event names and attributes.

func Attrs

func Attrs(s sdktrace.ReadOnlySpan) map[string]string

Attrs returns a span's attributes as strings, keyed by attribute name.

func Key

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

Key builds the key a series is stored under.

func Named

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

func Record

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

Record installs a span recorder as the global tracer provider for the rest of the test and restores the previous provider and propagator when the test ends. Tests that call it must not run in parallel.

Types

type Sink

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

Sink is a go-utils metrics sink that remembers every series it hands out, keyed as name{label=value,...} with the labels sorted.

func NewSink

func NewSink() *Sink

NewSink returns an empty sink.

func (*Sink) Counter

func (s *Sink) Counter(t *testing.T, key string) float64

Counter returns the value of the counter stored under key, failing the test when there is none.

func (*Sink) Gauge

func (s *Sink) Gauge(t *testing.T, key string) float64

Gauge returns the value of the gauge stored under key, failing the test when there is none.

func (*Sink) HistogramCount

func (s *Sink) HistogramCount(t *testing.T, key string) uint64

HistogramCount returns how many observations the histogram stored under key holds, failing the test when there is none.

func (*Sink) Metrics

func (s *Sink) Metrics() gometrics.Metrics

Metrics returns the sink as a go-utils Metrics, for SetMetrics and app.WithMetrics.

func (*Sink) Series

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

Series returns every key the sink has handed out, sorted.

Jump to

Keyboard shortcuts

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