Documentation
¶
Overview ¶
Package telemetrytest records what Trove's telemetry emits, for tests: a span recorder installed as the global tracer provider, and an observe.Recorder that remembers every measurement and checks it against the metric definitions in package observe.
Index ¶
- func Attr(s sdktrace.ReadOnlySpan, key string) (string, bool)
- func Key(name string, labelValues ...string) string
- func Leaks(rec *tracetest.SpanRecorder, value string) []string
- func Named(rec *tracetest.SpanRecorder, name string) []sdktrace.ReadOnlySpan
- func Spans(t *testing.T) *tracetest.SpanRecorder
- func SpansWithEnds(t *testing.T) (rec *tracetest.SpanRecorder, ends <-chan string)
- func WaitEnded(t *testing.T, ends <-chan string, name string)
- type Recorder
- func (r *Recorder) Add(name string, delta float64, labelValues ...string)
- func (r *Recorder) Count(name string, labelValues ...string) int
- func (r *Recorder) Counter(name string, labelValues ...string) float64
- func (r *Recorder) Observe(name string, value float64, labelValues ...string)
- func (r *Recorder) Series(name string) []string
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, formatted 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 a key, a bucket or a hash through the code asserts this is empty.
func Named ¶
func Named(rec *tracetest.SpanRecorder, name string) []sdktrace.ReadOnlySpan
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, and forge's default propagators (tracecontext and baggage) as the global propagator, for the rest of the test. The previous ones come back when the test ends.
func SpansWithEnds ¶
func SpansWithEnds(t *testing.T) (rec *tracetest.SpanRecorder, ends <-chan string)
SpansWithEnds is Spans, and also reports the name of each span as it ends, so a test can wait with WaitEnded for a span another goroutine ends instead of sleeping.
Types ¶
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is an observe.Recorder that keeps every measurement. It fails the test when a call names a metric observe does not declare, uses the wrong method for its kind, passes the wrong number of label values, or passes a value outside the documented set.
func NewRecorder ¶
NewRecorder returns an empty Recorder that reports misuse to t.