testing library
Test helpers: in-memory exporters and an on-demand metric reader.
Re-exports package:dartastic_opentelemetry/testing.dart. Import it from
test/ only; like the original, it is not part of the main library.
Classes
- InMemoryLogExporter
- Log-record exporter that buffers records in memory for inspection.
- InMemoryMetricExporter
- Metric exporter that buffers exported metric snapshots in memory.
- InMemorySpanExporter
- Span exporter that buffers spans in memory for inspection.
- OnDemandMetricReader
-
Metric reader for tests. Never fires on a timer; tests drive
collect()explicitly via TestHarness.collectMetrics so assertions don't race against a periodic export. - TestHarness
-
Bundles the three in-memory exporters and the on-demand metric
reader so tests have one handle to
clear()between cases.
Functions
-
maybeInitializeOtelForTest(
{String serviceName = 'otel-test', String endpoint = OTel.defaultEndpoint}) → Future< TestHarness> - Initializes the OpenTelemetry SDK once per test process with in-memory exporters for spans / logs / metrics, and returns the same TestHarness on subsequent calls.