Documentation
¶
Overview ¶
Package telemetrytest records the spans and metrics Nexus emits, so a test can assert on them without a Forge app.
Index ¶
- func AssertAbsent(t testing.TB, rec *tracetest.SpanRecorder, value string)
- func Attrs(span sdktrace.ReadOnlySpan) map[string]string
- func Named(rec *tracetest.SpanRecorder, name string) []sdktrace.ReadOnlySpan
- func Names(rec *tracetest.SpanRecorder) []string
- func One(t testing.TB, rec *tracetest.SpanRecorder, name string) sdktrace.ReadOnlySpan
- func Spans(t testing.TB) *tracetest.SpanRecorder
- type Series
- type Sink
- func (s *Sink) Counter(name string, opts ...gometrics.MetricOption) gometrics.Counter
- func (s *Sink) Find(name string, want map[string]string) (Series, bool)
- func (s *Sink) Histogram(name string, opts ...gometrics.MetricOption) gometrics.Histogram
- func (s *Sink) Names() []string
- func (s *Sink) Series(name string) []Series
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertAbsent ¶
func AssertAbsent(t testing.TB, rec *tracetest.SpanRecorder, value string)
AssertAbsent fails the test if value appears anywhere on any ended span: its name, an attribute, an event's name or attributes, or its status.
func Attrs ¶
func Attrs(span sdktrace.ReadOnlySpan) map[string]string
Attrs returns every attribute on span as strings.
func Named ¶
func Named(rec *tracetest.SpanRecorder, name string) []sdktrace.ReadOnlySpan
Named returns the ended spans called name, oldest first.
func Names ¶
func Names(rec *tracetest.SpanRecorder) []string
Names lists the names of the ended spans, oldest first.
func One ¶
func One(t testing.TB, rec *tracetest.SpanRecorder, name string) sdktrace.ReadOnlySpan
One returns the one ended span called name and fails the test unless there is exactly one.
Types ¶
type Series ¶
type Series struct {
Name string
Unit string
Labels map[string]string
// Value is a counter's total. Count and Sum are a histogram's.
Value float64
Count uint64
Sum float64
}
Series is one label set of one metric, as the sink recorded it.
type Sink ¶
Sink is a go-utils metrics sink that keeps every counter and histogram it hands out, so a test can read back names, units, labels and values. Only Counter and Histogram are implemented; anything else panics on the nil embedded interface.
func (*Sink) Find ¶
Find returns the series of name whose labels include every pair in want, and whether there was one.