Installation
Overview
The SDK testkit provides in-memory exporters and readers that allow you to:- Capture emitted spans and metrics in memory
- Assert on the telemetry data structure
- Test instrumentation without external dependencies
- Run fast, isolated unit tests
Key Features
Usage Pattern
The general pattern for using the SDK testkit:- Create an in-memory testkit instance
- Use the testkit’s tracer or meter provider in your code
- Execute your instrumented code
- Collect the emitted telemetry data
- Assert on the captured data
Benefits
- Fast Tests: No external services or network calls required
- Deterministic: Consistent results across test runs
- Isolated: Each test gets its own testkit instance
- Comprehensive: Access to all telemetry data for detailed assertions
When to Use
Use the SDK testkit when:- Testing custom instrumentation logic
- Verifying span structure and attributes
- Validating metric values and labels
- Running CI/CD pipelines without external dependencies
- Developing instrumentation libraries
For production use cases or testing with the OpenTelemetry Java SDK, use the OtelJava Testkit instead.