Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
Main is a helper function that initializes OTel and runs the tests before exiting. Use it in your TestMain function.
Main covers initializing the OTel trace and logger providers, pointing to standard OTEL_* env vars.
It also initializes a context that will be used to propagate trace context to subtests.
func WithLogging ¶
func WithLogging[T testctx.Runner[T]](cfg ...LogConfig) testctx.Middleware[T]
WithLogging creates middleware that adds OpenTelemetry logging to each test/benchmark
func WithTracing ¶
func WithTracing[T testctx.Runner[T]](cfg ...TraceConfig[T]) testctx.Middleware[T]
WithTracing creates middleware that adds OpenTelemetry tracing around each test/benchmark
Types ¶
type LogConfig ¶
type LogConfig struct { // LoggerProvider to use for logging. If nil, the global provider will be used. LoggerProvider *sdklog.LoggerProvider // Attributes to add to all test logs Attributes []log.KeyValue }
LogConfig holds configuration for the OpenTelemetry logging middleware
type TraceConfig ¶
type TraceConfig[T testctx.Runner[T]] struct { // TracerProvider to use for creating spans. If nil, the global provider will be used. TracerProvider trace.TracerProvider // Attributes to add to all test spans Attributes []attribute.KeyValue // StartOptions allows customizing the span start options for each test/benchmark StartOptions func(*testctx.W[T]) []trace.SpanStartOption }
TraceConfig holds configuration for the OpenTelemetry tracing middleware
Click to show internal directories.
Click to hide internal directories.