Documentation
¶
Index ¶
- func CountSpansWithPrefix(spans []*RecordingSpan, prefix string) int
- func SpanNames(spans []*RecordingSpan) []string
- type RecordingEvent
- type RecordingSpan
- func (span *RecordingSpan) AddEvent(name string, attrs ...observability.Attribute)
- func (span *RecordingSpan) Attribute(key string) (any, bool)
- func (span *RecordingSpan) End()
- func (span *RecordingSpan) Ended() bool
- func (span *RecordingSpan) Events() []RecordingEvent
- func (span *RecordingSpan) Name() string
- func (span *RecordingSpan) Options() observability.SpanOptions
- func (span *RecordingSpan) RecordError(err error)
- func (span *RecordingSpan) RequireAttribute(t testing.TB, key string) any
- func (span *RecordingSpan) RequireAttributeValue(t testing.TB, key string, want any)
- func (span *RecordingSpan) RequireEnded(t testing.TB)
- func (span *RecordingSpan) RequireEvent(t testing.TB, name string)
- func (span *RecordingSpan) RequireOmittedAttribute(t testing.TB, key string)
- func (span *RecordingSpan) RequireOptionalStringAttribute(t testing.TB, key string, wantPresent bool, contains string)
- func (span *RecordingSpan) SetAttributes(attrs ...observability.Attribute)
- func (span *RecordingSpan) SetError(message string)
- type RecordingTracer
- func (*RecordingTracer) ExtractTraceContext(ctx context.Context) map[string]string
- func (tracer *RecordingTracer) LastSpan(t testing.TB) *RecordingSpan
- func (tracer *RecordingTracer) Spans() []*RecordingSpan
- func (tracer *RecordingTracer) Start(ctx context.Context, name string, options observability.SpanOptions) (context.Context, observability.Span)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountSpansWithPrefix ¶
func CountSpansWithPrefix(spans []*RecordingSpan, prefix string) int
CountSpansWithPrefix returns the number of spans whose name starts with prefix.
func SpanNames ¶
func SpanNames(spans []*RecordingSpan) []string
SpanNames returns span names for assertion failures.
Types ¶
type RecordingEvent ¶
type RecordingEvent struct {
Name string
Attributes []observability.Attribute
}
RecordingEvent records a span event.
type RecordingSpan ¶
type RecordingSpan struct {
// contains filtered or unexported fields
}
RecordingSpan records workflow span operations for tests.
func FindSpanWithPrefix ¶
func FindSpanWithPrefix(t testing.TB, spans []*RecordingSpan, prefix string) *RecordingSpan
FindSpanWithPrefix returns the first span whose name starts with prefix.
func (*RecordingSpan) AddEvent ¶
func (span *RecordingSpan) AddEvent(name string, attrs ...observability.Attribute)
func (*RecordingSpan) Attribute ¶
func (span *RecordingSpan) Attribute(key string) (any, bool)
Attribute returns a recorded attribute value.
func (*RecordingSpan) End ¶
func (span *RecordingSpan) End()
func (*RecordingSpan) Ended ¶
func (span *RecordingSpan) Ended() bool
Ended reports whether End was called.
func (*RecordingSpan) Events ¶
func (span *RecordingSpan) Events() []RecordingEvent
Events returns a snapshot of recorded events.
func (*RecordingSpan) Options ¶
func (span *RecordingSpan) Options() observability.SpanOptions
Options returns the span start options.
func (*RecordingSpan) RecordError ¶
func (span *RecordingSpan) RecordError(err error)
func (*RecordingSpan) RequireAttribute ¶
func (span *RecordingSpan) RequireAttribute(t testing.TB, key string) any
RequireAttribute fails the test if the span does not include the attribute.
func (*RecordingSpan) RequireAttributeValue ¶
func (span *RecordingSpan) RequireAttributeValue(t testing.TB, key string, want any)
RequireAttributeValue fails the test if the span attribute is missing or not equal to want.
func (*RecordingSpan) RequireEnded ¶
func (span *RecordingSpan) RequireEnded(t testing.TB)
RequireEnded fails the test if End was not called.
func (*RecordingSpan) RequireEvent ¶
func (span *RecordingSpan) RequireEvent(t testing.TB, name string)
RequireEvent fails the test if the span does not include the named event.
func (*RecordingSpan) RequireOmittedAttribute ¶
func (span *RecordingSpan) RequireOmittedAttribute(t testing.TB, key string)
RequireOmittedAttribute fails if the span includes the attribute.
func (*RecordingSpan) RequireOptionalStringAttribute ¶
func (span *RecordingSpan) RequireOptionalStringAttribute(t testing.TB, key string, wantPresent bool, contains string)
RequireOptionalStringAttribute fails if presence or string content does not match expectations.
func (*RecordingSpan) SetAttributes ¶
func (span *RecordingSpan) SetAttributes(attrs ...observability.Attribute)
func (*RecordingSpan) SetError ¶
func (span *RecordingSpan) SetError(message string)
type RecordingTracer ¶
type RecordingTracer struct {
// contains filtered or unexported fields
}
RecordingTracer records workflow observability spans for tests.
func NewRecordingTracer ¶
func NewRecordingTracer() *RecordingTracer
NewRecordingTracer creates an empty workflow telemetry recorder.
func (*RecordingTracer) ExtractTraceContext ¶
func (*RecordingTracer) ExtractTraceContext(ctx context.Context) map[string]string
func (*RecordingTracer) LastSpan ¶
func (tracer *RecordingTracer) LastSpan(t testing.TB) *RecordingSpan
LastSpan returns the most recently started span.
func (*RecordingTracer) Spans ¶
func (tracer *RecordingTracer) Spans() []*RecordingSpan
Spans returns a snapshot of spans started by this tracer.
func (*RecordingTracer) Start ¶
func (tracer *RecordingTracer) Start(ctx context.Context, name string, options observability.SpanOptions) (context.Context, observability.Span)