Help us shape the future of Go! Take the 2026 Go Developer Survey

telemetrytest

package
v1.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetrytest records what Chronicle'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 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 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 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 for the rest of the test and puts the previous provider back when the test ends.

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 a component 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