Documentation
¶
Overview ¶
Package oteltest installs a span recorder for Dispatch's tests and checks what the recorded spans may and may not carry.
Index ¶
- func AssertNoValue(t *testing.T, spans []sdktrace.ReadOnlySpan, needle string)
- func Attr(s sdktrace.ReadOnlySpan, key string) (string, bool)
- func ChildOf(child, parent sdktrace.ReadOnlySpan) bool
- func IsRoot(s sdktrace.ReadOnlySpan) bool
- func LinksTo(s sdktrace.ReadOnlySpan, sc trace.SpanContext) bool
- func Named(spans []sdktrace.ReadOnlySpan, name string) []sdktrace.ReadOnlySpan
- func SpanContext(t *testing.T) context.Context
- type Recorder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNoValue ¶
func AssertNoValue(t *testing.T, spans []sdktrace.ReadOnlySpan, needle string)
AssertNoValue fails when any span quotes needle in its name, status, attributes or event attributes. Feed a personal value (an email address) through a payload or an error and check it never reaches a span.
func Attr ¶
func Attr(s sdktrace.ReadOnlySpan, key string) (string, bool)
Attr returns the value of key on s as a string, and whether it is set.
func ChildOf ¶
func ChildOf(child, parent sdktrace.ReadOnlySpan) bool
ChildOf reports whether child's parent is parent.
func LinksTo ¶
func LinksTo(s sdktrace.ReadOnlySpan, sc trace.SpanContext) bool
LinksTo reports whether s links to sc.
func Named ¶
func Named(spans []sdktrace.ReadOnlySpan, name string) []sdktrace.ReadOnlySpan
Named returns the ended spans called name.
Types ¶
type Recorder ¶
type Recorder struct {
*tracetest.SpanRecorder
// contains filtered or unexported fields
}
Recorder is a span recorder that also signals each span's end, so a test can wait for a span without sleeping.
func NewRecorder ¶
func NewRecorder() *Recorder
NewRecorder returns a Recorder that is not installed anywhere. Register it with forge.RegisterSpanProcessor to record a Forge app's spans.
func Record ¶
Record installs a recording tracer provider as the global provider and restores the previous one when the test ends. Tests that call it must not run in parallel with other tests that read the global provider.
func (*Recorder) OnEnd ¶
func (r *Recorder) OnEnd(s sdktrace.ReadOnlySpan)
OnEnd implements sdktrace.SpanProcessor.