telemetrytest

package
v1.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetrytest records what herald's telemetry emits, for tests: a span recorder installed as the global tracer provider, and a go-utils metrics sink that remembers every series registered on it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attrs

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

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

func ExceptionTypes

func ExceptionTypes(s sdktrace.ReadOnlySpan) []string

ExceptionTypes returns the exception.type of every exception event on s.

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 personal data or a secret through the code asserts this is empty.

func Named

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

func One

One returns the only ended span called name, failing the test otherwise.

func Spans

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

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

Types

type Series

type Series struct {
	Name    string
	Kind    string // counter or histogram
	Labels  map[string]string
	Unit    string
	Buckets []float64
	// contains filtered or unexported fields
}

Series is one metric series registered on a Sink.

func (*Series) Value

func (s *Series) Value() float64

Value is a counter's value, or a histogram's observation count.

type Sink

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

Sink is a go-utils metrics.Metrics that remembers every counter and histogram registered on it, keyed by name and labels.

func NewSink

func NewSink() *Sink

NewSink returns an empty Sink.

func (*Sink) All

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

All returns every series registered under name.

func (*Sink) Get

func (s *Sink) Get(name string, labels ...string) *Series

Get returns the series name{labels}, where labels alternate key and value, or nil if nothing registered it.

func (*Sink) Names

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

Names returns every metric name registered, sorted.

Jump to

Keyboard shortcuts

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