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 ¶ added in v0.0.2
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) testctx.Middleware[T]
WithTracing creates middleware that adds OpenTelemetry tracing around each test/benchmark
Types ¶
type LogConfig ¶ added in v0.0.2
type LogConfig struct {
// LoggerProvider to use for logging. If nil, the global provider will be used.
LoggerProvider *sdklog.LoggerProvider
}
LogConfig holds configuration for the OpenTelemetry logging middleware
type TraceConfig ¶ added in v0.0.2
type TraceConfig 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
}
TraceConfig holds configuration for the OpenTelemetry tracing middleware
Click to show internal directories.
Click to hide internal directories.