Skip to content

chore: OpenTelemetry SDK to v2 with compat matrix#361

Merged
jithinraj merged 8 commits intomainfrom
chore/otel-sdk-metrics-v2
Feb 13, 2026
Merged

chore: OpenTelemetry SDK to v2 with compat matrix#361
jithinraj merged 8 commits intomainfrom
chore/otel-sdk-metrics-v2

Conversation

@jithinraj
Copy link
Member

Summary

  • Upgrade @opentelemetry/sdk-metrics and sdk-trace-base from v1 to ^2.0.0 (dev deps only)
  • Bump @opentelemetry/api peer dep to ^1.9.0 (still stable 1.x)
  • Fix breaking API: BasicTracerProvider.addSpanProcessor() -> constructor spanProcessors option
  • Update example exporter to ^0.200.0 (version-locked to SDK v2)
  • Add compatibility matrix to telemetry-otel README

Roadmap tie-in

v0.10.11 PR 3.2 -- dev dependency modernization.

Risk level

Low. SDK packages are dev dependencies only -- NOT shipped to consumers. @opentelemetry/api (the only production peer dep) stays at stable v1. No runtime behavior changes for consumers.

Compatibility matrix

Dependency Role Version Notes
@opentelemetry/api Peer dep (production) ^1.9.0 Stable, backward-compatible
@opentelemetry/sdk-metrics Dev dep (tests) ^2.0.0 Not shipped to consumers
@opentelemetry/sdk-trace-base Dev dep (tests) ^2.0.0 Not shipped to consumers
@opentelemetry/exporter-* Example only ^0.200.0 Coupled to SDK v2 release train

Gates

  • pnpm build
  • pnpm lint
  • pnpm typecheck:core
  • pnpm test
  • bash scripts/guard.sh

Test plan

  • Verify telemetry-otel tests pass with SDK v2
  • Verify example builds with updated exporter
  • Verify no OTel SDK deps leak into published package

- @opentelemetry/sdk-metrics: ^1.29.0 -> ^2.0.0
- @opentelemetry/sdk-trace-base: ^1.29.0 -> ^2.0.0
- @opentelemetry/exporter-trace-otlp-http: ^0.57.1 -> ^0.200.0
- @opentelemetry/api peer dep: ^1.7.0 -> ^1.9.0
- Migrate BasicTracerProvider.addSpanProcessor() to constructor
  spanProcessors option (removed in SDK v2)
- Production code unchanged (uses only @opentelemetry/api)
Documents the supported @opentelemetry/api, SDK, and Node.js versions.
Clarifies that SDK packages are dev-only (not shipped to consumers)
and explains the OTel experimental version scheme for exporters.
- Add peerDependenciesMeta to document @opentelemetry/api as required
- Clarify in README that SDK packages are not needed by consumers
- Package uses only the API facade; consumers bring their own SDK
Verify @peac/telemetry-otel works with only @opentelemetry/api
(no SDK packages). Four tests:

- All public exports resolve via dynamic import
- createOtelProvider works with no-op API (no SDK registered)
- Provider methods do not throw with no-op meter/tracer
- package.json: SDK packages are devDependencies only

Also applies Prettier formatting to README.md.
Add scripts/otel-smoke.sh that packs @peac/telemetry-otel and its
workspace deps into tarballs, installs them in a temp project with only
@opentelemetry/api, and verifies createOtelProvider resolves and works.

Fix exports maps for @peac/privacy and @peac/telemetry-otel: add
"default" condition so CJS require() resolves correctly when loaded
outside the workspace (the smoke test caught this).
Robustness improvements:
- Use parallel arrays instead of associative arrays (bash compat)
- Pin @opentelemetry/api to peer range from package.json, not @latest
- Deterministic package directory map instead of pnpm --filter exec pwd
- Assert tarball files exist with diagnostics on failure
- Verify resolved dependency tree has all expected packages

Wire the smoke test into CI as a step after pack-and-install gate.
The domain guard forbids npm invocations outside an allowlist.
otel-smoke.sh uses npm install to simulate consumer installs
from tarballs, which is an intentional npm usage pattern
(same as pack-install-smoke.sh).
- Portable shebang (#!/usr/bin/env bash)
- Assert OTEL_API_RANGE is non-empty before proceeding
- Use argv array for pnpm filter args (no string-splitting)
- Add --ignore-scripts --no-package-lock to npm install
- Remove 2>/dev/null from pnpm pack (failures should be visible)
@jithinraj jithinraj force-pushed the chore/otel-sdk-metrics-v2 branch from 8a64cc4 to fd47244 Compare February 13, 2026 21:32
@jithinraj jithinraj changed the title chore: upgrade OpenTelemetry SDK to v2 with compat matrix chore: OpenTelemetry SDK to v2 with compat matrix Feb 13, 2026
@jithinraj jithinraj merged commit 341b542 into main Feb 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant