tracetest

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertContainNotTraceSpan

func AssertContainNotTraceSpan(tb testing.TB, exporter TestTraceExporter, expectedName string, expectedAttributes ...attribute.KeyValue) bool

AssertContainNotTraceSpan allows to assert if a trace span partially matching provided name and attributes cannot be found.

func AssertContainTraceSpan

func AssertContainTraceSpan(tb testing.TB, exporter TestTraceExporter, expectedName string, expectedAttributes ...attribute.KeyValue) bool

AssertContainTraceSpan allows to assert if a trace span partially matching provided name and attributes can be found.

func AssertHasNotTraceSpan

func AssertHasNotTraceSpan(tb testing.TB, exporter TestTraceExporter, expectedName string, expectedAttributes ...attribute.KeyValue) bool

AssertHasNotTraceSpan allows to assert if a trace span exactly matching provided name and attributes cannot be found.

func AssertHasTraceSpan

func AssertHasTraceSpan(tb testing.TB, exporter TestTraceExporter, expectedName string, expectedAttributes ...attribute.KeyValue) bool

AssertHasTraceSpan allows to assert if a trace span exactly matching provided name and attributes can be found.

Types

type DefaultTestTraceExporter

type DefaultTestTraceExporter struct {
	*tracetest.InMemoryExporter
}

DefaultTestTraceExporter is the default TestTraceExporter implementation.

func (*DefaultTestTraceExporter) ContainSpan

func (e *DefaultTestTraceExporter) ContainSpan(expectedName string, expectedAttributes ...attribute.KeyValue) bool

ContainSpan return true if a trace span from the in memory internal buffer is partially matching provided name and attributes.

func (*DefaultTestTraceExporter) Dump added in v1.1.0

func (e *DefaultTestTraceExporter) Dump()

Dump prints the tracetest.SpanStubs snapshots from the in memory internal exporter, for debugging purposes.

func (*DefaultTestTraceExporter) Exporter

Exporter returns the in memory internal exporter.

func (*DefaultTestTraceExporter) HasSpan

func (e *DefaultTestTraceExporter) HasSpan(expectedName string, expectedAttributes ...attribute.KeyValue) bool

HasSpan return true if a trace span from the in memory internal buffer is exactly matching provided name and attributes.

func (*DefaultTestTraceExporter) Reset

Reset resets the in memory internal exporter.

func (*DefaultTestTraceExporter) Span

Span get a specific tracetest.SpanStub from the in memory internal exporter by name.

func (*DefaultTestTraceExporter) Spans

Spans get the tracetest.SpanStubs from the in memory internal exporter.

type TestTraceExporter

type TestTraceExporter interface {
	trace.SpanExporter
	Exporter() trace.SpanExporter
	Reset() TestTraceExporter
	Spans() tracetest.SpanStubs
	Span(name string) (tracetest.SpanStub, error)
	HasSpan(expectedName string, expectedAttributes ...attribute.KeyValue) bool
	ContainSpan(expectedName string, expectedAttributes ...attribute.KeyValue) bool
	Dump()
}

TestTraceExporter is the interface for test trace span exporters.

func NewDefaultTestTraceExporter

func NewDefaultTestTraceExporter() TestTraceExporter

NewDefaultTestTraceExporter returns a DefaultTestTraceExporter, implementing TestTraceExporter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL