telemetrytest

package
v1.9.1 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetrytest holds what ledger's tests use to see its telemetry: a span recorder installed as the global tracer provider, and a metrics sink that keeps every series it hands out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNoValue

func AssertNoValue(t *testing.T, rec *tracetest.SpanRecorder, value string)

AssertNoValue fails the test if value appears anywhere on an ended span: its name, an attribute, an event or its status.

func Attr

Attr returns the value of the attribute key on s.

func Named

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

func Names

func Names(rec *tracetest.SpanRecorder) []string

Names lists the names of the ended spans.

func Only

Only returns the one ended span called name, and fails the test unless there is exactly one.

func RecordSpans

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

RecordSpans installs a span recorder as the global tracer provider until the test ends, then puts the previous provider back.

Types

type Sink

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

Sink is a go-utils metrics registry that keeps every counter and histogram it hands out, keyed the way Prometheus prints a series: name{key="value",...}, keys sorted.

func NewSink

func NewSink() *Sink

NewSink returns an empty Sink.

func (*Sink) AssertOneLabelSet

func (s *Sink) AssertOneLabelSet(t *testing.T)

AssertOneLabelSet fails the test if two series of one metric carry different label keys.

func (*Sink) Observations

func (s *Sink) Observations(series string) uint64

Observations returns how many values a histogram series has seen, zero if it was never created.

func (*Sink) Series

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

Series lists every series created, sorted.

func (*Sink) Value

func (s *Sink) Value(series string) float64

Value returns the value of a counter series, zero if it was never created.

Jump to

Keyboard shortcuts

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