Skip to content

feat(diagnostics-otel): migrate to OpenTelemetry 3 - #189667

Open
roboclaw-bot wants to merge 2 commits into
mainfrom
openclaw/mig-opentelemetry-3
Open

roboclaw-bot wants to merge 2 commits into
mainfrom
openclaw/mig-opentelemetry-3

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Move the diagnostics exporter to the age-qualified OpenTelemetry SDK 3 without breaking existing propagation or collector settings.

User Impact

Configured trace, metric, and log exports, sampling and span limits, resource attributes, and generation-private flush/shutdown behavior are retained. Deprecated OTEL_PROPAGATORS=jaeger still reads and writes uber-trace-id and uberctx-* baggage; no cross-service header migration is forced.

Why This Change Was Made

  • Adopt SDK 3.0.0, experimental 0.300.0, and API 1.10.0. Logs API moves into @opentelemetry/api; sdk-trace replaces sdk-trace-base. Follow the 3.x migration guide.
  • There is no compatible published Jaeger propagator. Upstream removed it in #7077; its last 2.12.0 release requires API <1.10. W3C TraceContext is not wire-compatible. A plugin-owned adapter preserves the shipped default-header behavior, baggage encoding, and tracing suppression, with fixtures also executed against upstream 2.12.0.
  • SDK 3 private tracer providers stop reading sampler/span-limit environment variables. Preserve that documented contract explicitly; leave exporter configuration and lifecycle ownership with their existing owners.
  • SDK Node 0.300.0 becomes a plugin test-only dependency. Root and packages/ai get development API 1.9.1 pins so Mistral's optional SDK 2 peers remain compatible, without new peer overrides or changes to public peer contracts.

Versions and holds

  • Plugin API 1.9.1 → 1.10.0; context/core/B3/resources/metrics 2.12.0 → 3.0.0; logs SDK 0.223.0 → 3.0.0; protobuf exporters and SDK Node 0.223.0 → 0.300.0. Replace trace-base 2.12.0 with trace 3.0.0; remove standalone API Logs and Jaeger from the plugin.
  • Audit 2026-10-31T16:54:00Z, inclusive cutoff 2026-10-24T16:54:00Z. All 25 introduced package identities were published October 20. The native multi-document lock audit found no new non-OTel identities, age violations, or downgraded edges of unchanged parents. Frozen installation passes; release-age exclusions are unchanged.
  • Hold semantic conventions at 1.43.0: 1.44.0 was published 2026-10-28T20:49:19.974Z, after the cutoff.
  • Retain Mistral's SDK 2 optional peers and the existing core 2.12.0 override, narrowed to major 2. Both Mistral 2.7.0 and age-qualified 3.2.0 require resources/trace-base ^2.9 and exporter ^0.220. Do not silently remove @openclaw/ai public peers. The inherited Mistral exporter ^0.220/0.223 peer warning remains; new OTel API peer violations are resolved.
  • Related, not incorporated: #184661 (generic cache usage attributes) and #158145 (content-capture stall). Their behavior-owning hunks are untouched; shared import/test edits may need normal integration.

Evidence

  • pnpm test:extension diagnostics-otel: 13 files, 149 tests passed, 8m12s wrapper wall / 446.52s Vitest. Covers real OTLP receivers, propagation, resources, sampling, TLS, external ownership, and restart flush/shutdown.
  • Final SDK-peer isolation: four real-consumer files rerun, 48 passed, 515.60s wrapper wall / 447.83s Vitest. These are a subset of the 149, not additional unique tests.
  • Jaeger: five fixtures pass against both the local adapter and upstream 2.12.0; a temporary identity assertion verified the actual upstream class was substituted.
  • Passed: native plugin npm-runtime build (3 entries); extension production/test and final root-E2E typechecks; changed-extension and final root-E2E standalone oxlint/pinned-Bun diagnostic parity (zero warnings/errors); oxfmt/Bun formatting parity; frozen install; test-line ratchet; git diff --check; docs links (16,194 checked, zero broken).
  • Native Node ESM smoke passes SDK 3 public entrypoints, private tracer resource/force-flush/shutdown, stable Logs API, context manager, and all three OTLP exporter constructors without a bundler. This is not a Gateway/model-turn proof.
  • Current-head CI is green: run 41231060684, 181 successful, 69 skipped, 1 neutral check results; no failures or pending checks. openclaw/ci-gate, security-fast, and security-sensitive review report success for 2b57294febc1552db62d910dfa1bd0b77c09c891. No CI rerun, merge, or auto-merge was requested. Test-specific CI seconds were not collected.
  • Installed-plugin Gateway E2E remains unproven. Local setup refused before tests: Cannot verify that test preparation is separate from managed Gateway artifacts; no checkout artifacts were rebuilt. The configured Blacksmith Testbox fallback was stopped after more than ten minutes of local source-capsule preparation, still in git update-index --refresh, before remote allocation/run. No lease ID, Actions URL, or remote test result was produced. No provider fallback or guard bypass was used.
  • A repeated extension-boundary declaration prerequisite hit its unchanged 300-second timeout before lint. Retain the earlier passing extension parity result; do not call this prerequisite failure a product failure or passing proof. Task-owned interrupted artifact claims were recovered only after checking their recorded processes and descendants had stopped.
  • Independent autoreview / Codex, P0–P2: terminal scoped-clean, no findings, complete candidate against 1df551011c87ddab2b6e6edb316682cd8a9de1f2, including final source verification. It checked upstream contracts statically, not test execution/publication dates. Published head has the same source tree as the reviewed implementation commit.
  • Simplification retires plugin use of the old trace-base shim, API Logs, and Jaeger packages. Necessary adapter/configuration growth: +171 net production TypeScript lines, +100 net test lines. The separate 100-line regression allocation protects the removed dependency's wire contract; the shared test ceiling is unchanged.

Requested and guided by @steipete.

Work sessions

Worked on by

roboclaw-bot and others added 2 commits October 31, 2026 18:40
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 26cfaf52-dd15-4d43-b780-6a2bda3812b0
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel size: M labels Oct 31, 2026
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Oct 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Dependency graph changes

This maintainer PR changes the dependency graph.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 2b57294febc1552db62d910dfa1bd0b77c09c891
  • Maintainer: @roboclaw-bot
  • Repository role: maintain

These dependency graph changes were made:

  • pnpm-lock.yaml
  • pnpm-workspace.yaml
  • extensions/diagnostics-otel/package.json
  • package.json
  • packages/ai/package.json

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR migrates diagnostics-otel to OpenTelemetry SDK 3 while preserving existing exporter settings and Jaeger propagation.

Example: Run with OTEL_PROPAGATORS=jaeger and baggage value "a b/ü".

  • Before: The upstream Jaeger package exports uber-trace-id and percent-encoded uberctx-* headers.
  • After: A plugin-owned adapter preserves those headers while the exporters use SDK 3.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful compatibility-focused migration with supporting SDK coverage, but a definite preload regression prevents a clean review.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Maintenance · Worth it: Yes · Fix scope: Complete
User problem: Users need the diagnostics exporter to adopt SDK 3 without losing their existing telemetry configuration or cross-service trace correlation.
Reason: The maintainer-authored direction is established, and plugin-local compatibility adapters are justified by shipped propagation and environment contracts.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: this maintainer-authored migration has a concrete regression for existing SDK 2 preloads.

Priority: P2
Reviewed head: 2b57294febc1552db62d910dfa1bd0b77c09c891

Before merge

  • Preserve telemetry from SDK 2 preloads when upgrading the API (P1) - With OPENCLAW_OTEL_PRELOADED=1 and an existing SDK 2 preload using API 1.9.1, the preload registers the global registry before the plugin loads. API 1.10 rejects that older registry in getGlobal, so the unchanged metrics.getMeter and trace.getTracer calls in service.ts return no-op providers. OpenClaw still reports that it is using the preloaded SDK, but its traces and metrics disappear. This was a supported path before the dependency change, and replacing the E2E fixture with SDK 3 hides it. Preserve interoperability at the existing preload boundary and retain coverage with the older external API registry.
  • Explain or restore the original intent of Host-owned preloaded providers - 56eb1ff: Allow hosts with an existing global SDK to retain that SDK while OpenClaw continues recording diagnostic events; the later private-provider refactor explicitly preserved this behavior.

Findings

  • [P1] Preserve telemetry from SDK 2 preloads when upgrading the API — extensions/diagnostics-otel/package.json:11

Provenance

  • Host-owned preloaded providers changes intended behavior without addressing why it exists (56eb1ff: Allow hosts with an existing global SDK to retain that SDK while OpenClaw continues recording diagnostic events; the later private-provider refactor explicitly preserved this behavior.)

Tests

  • Low-value test test/e2e/qa-lab/runtime/diagnostics-otel-install-runtime.e2e.test.ts: Remove the changed root/plugin dependency-location and exact-version assertions from this runtime scenario; they pin package metadata and belong in the generic package ownership contracts.
  • Missing end-to-end proof: Provide installed-plugin Gateway evidence for fresh installation and an upgrade from v2026.10.9 with settings intact, including an API 1.9 SDK 2 preload; no base-red/head-green regression for that boundary is shown.
Agent review details

How this fits together

The diagnostics plugin converts Gateway diagnostic events into traces, metrics, and logs, using private providers or externally preloaded providers to send telemetry to collectors.

flowchart LR
  A[Gateway diagnostic events] --> B[Diagnostics plugin]
  C[Config and environment] --> B
  B --> D[Private SDK providers]
  B --> E[Preloaded global providers]
  D --> F[OTLP collector]
  E --> F
Loading

Technical review

Best possible solution:

Complete the SDK 3 migration while preserving access to existing host-owned SDK 2 providers through the established preload boundary.

Do we have a high-confidence way to reproduce the issue?

The SDK 2 preload failure follows directly from the plugin's API upgrade, the unchanged host-provider lookup path, and upstream's minor-version compatibility check; no runtime reproduction was executed.

Is this the best way to solve the issue?

The migration is focused, and the Jaeger adapter and sampler configuration preserve contracts removed upstream, but changing the preload fixture to SDK 3 leaves existing SDK 2 interoperability broken.

Full review comments:

  • [P1] Preserve telemetry from SDK 2 preloads when upgrading the API — extensions/diagnostics-otel/package.json:11
    With OPENCLAW_OTEL_PRELOADED=1 and an existing SDK 2 preload using API 1.9.1, the preload registers the global registry before the plugin loads. API 1.10 rejects that older registry in getGlobal, so the unchanged metrics.getMeter and trace.getTracer calls in service.ts return no-op providers. OpenClaw still reports that it is using the preloaded SDK, but its traces and metrics disappear. This was a supported path before the dependency change, and replacing the E2E fixture with SDK 3 hides it. Preserve interoperability at the existing preload boundary and retain coverage with the older external API registry.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ed79334f5b72.

Provenance checked

  • Generation-private trace and metric providers keeps the original intent (3bc188e: Prevent restarted plugin generations from continuing to export through shutdown global providers.)
  • Jaeger propagation keeps the original intent (095227d: Preserve configured propagation independently of exporter enablement; the replacement retains the upstream default wire format after its package removal.)
  • Sampler and span-limit environment configuration keeps the original intent (3bc188e: Private providers retained NodeSDK environment behavior; SDK 3 removes that implicit handling, so the plugin now supplies it explicitly.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test:extension diagnostics-otel
  • node scripts/run-vitest.mjs run test/e2e/qa-lab/runtime/diagnostics-otel-install-runtime.e2e.test.ts
  • git diff --check

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 095227d adds extensions/diagnostics-otel/src/service-propagation.ts:81 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 095227dd2152; files: extensions/diagnostics-otel/src/service-propagation.ts)
  • SunnyShu: Raw commit 3bc188e adds extensions/diagnostics-otel/src/service.ts:494 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3bc188efe55e; files: extensions/diagnostics-otel/src/service.ts)
  • Peter Steinberger: Raw commit 46aaa58 adds extensions/diagnostics-otel/src/service.ts:499 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 46aaa582b915; files: extensions/diagnostics-otel/src/service.ts)

PR surface

Source +171, Tests +100, Docs +7, Config 0, Other +74. Total +352 across 21 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 190 19 +171
Tests 8 144 44 +100
Docs 1 7 0 +7
Config 4 17 17 0
Generated 0 0 0 0
Other 2 292 218 +74
Total 21 650 298 +352

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is an optional diagnostics dependency migration with a compatibility defect affecting externally preloaded telemetry.
  • merge-risk: 🚨 compatibility: An existing API 1.9 preload becomes invisible to the plugin's API 1.10 consumers, silently suppressing traces and metrics.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 31, 2026, 3:22 PM ET / 19:22 UTC.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation extensions: diagnostics-otel Extension: diagnostics-otel gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant