@open-infra/telemetry-testing
v0.2.0
Published
Shared in-memory exporters and server, browser and mobile runtime test factories.
Maintainers
Readme
@open-infra/telemetry-testing
Shared in-memory exporters and runtime factories for meaningful telemetry tests. Nothing is sent to a collector. Each factory supplies the same exporter interfaces used in production.
import { createMobileTestTelemetry } from '@open-infra/telemetry-testing/mobile';
import { assertTelemetryExcludes } from '@open-infra/telemetry-testing';
const { runtime, spans } = createMobileTestTelemetry();
await runtime.start();
await runtime.setConsent('granted');
runtime.recordLifecycle('mobile.startup');
await runtime.forceFlush();
assertTelemetryExcludes(spans.getFinishedSpans(), ['SECRET_SENTINEL']);
await runtime.shutdown();/server, /browser and /mobile expose the corresponding factory. The root exposes createMemoryTelemetryExporters() and the privacy assertion. Browser tests need a DOM environment; consent defaults to unknown so tests must explicitly grant it. Server runtimes own process-lifetime globals: isolate server-runtime tests in fresh processes rather than attempting to restart a stopped global runtime. The factories disable automatic instrumentation/network exporters by default, and shutdown remains the test's responsibility.
