Repository navigation
fix(diagnostics-otel): propagate exported span context - #112283
vincentkoc merged 4 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 8:35 PM ET / August 6, 2026, 00:35 UTC. ClawSweeper reviewWhat this changesThis PR makes outbound model requests use the actual OpenTelemetry context of the exported model span instead of OpenClaw’s separate diagnostic correlation ID. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo blocking correctness finding: the exact-head bridge records and propagates exporter-owned span context, resolving the split-trace and dangling-parent reports. Merge still needs an explicit maintainer disposition for the additive plugin service-context capability. Priority: P2 Review scores
Verification
How this fits togetherAgent diagnostics emit model-call events that the diagnostics OpenTelemetry plugin turns into spans. Before a provider request leaves OpenClaw, the model-call path now obtains the exporter-created span context and serializes it as a W3C trace header. flowchart LR
A[Agent run] --> B[Diagnostic event]
B --> C[Diagnostics OpenTelemetry plugin]
C --> D[Exported model span]
D --> E[Outbound trace header]
E --> F[Provider or downstream trace]
Decision needed
Why: The change is additive and capability-gated, but Before merge
Agent review detailsSecurityNone. PR surfaceSource +242, Tests +513, Docs +4. Total +759 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one exporter-owned propagation path, explicitly accept the narrow trusted diagnostics service capability, and retain the real-SDK OTLP regression that proves every propagated parent is exported. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main formats diagnostic identifiers into outbound headers, while the exact-head real-SDK OTLP regression proves the corrected exporter-context path. Is this the best way to solve the issue? Yes: recording the exporter-owned context at span creation avoids both synthetic parents and custom OpenTelemetry ID generation, while preserving diagnostic IDs as correlation keys. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 678a3c18a941. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
Validated this PR against real traffic. It does what it says: with the patch applied, one agent Resulting trace, 377 spans, two services:
A gotcha for anyone else validating this PR. We first concluded the patch had not worked, One thing this PR does not fix, and probably should be landed alongside #112486. In the The practical effect is that the spans are correctly grouped but the hierarchy is not fully Environment: gateway |
d797592 to
d9ce523
Compare
…context Fall back to internalOrTrustedParentContext when there is no active tracked parent, so the openclaw.harness.run root span (and its whole OTel subtree) adopts the diagnostic traceId instead of minting a new OTel root. This lets spans propagated via the diagnostic traceparent (e.g. a2a-gateway a2a.call / downstream a2a.task) share one trace with the run internals.
Co-authored-by: HughTang <[email protected]>
37ac1b9 to
510ba03
Compare
|
@clawsweeper re-review Exact head: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
510ba03 to
3c246e1
Compare
|
Exact-head real OTLP proof for Command: node scripts/run-vitest.mjs extensions/diagnostics-otel/src/service.otlp-export.test.tsObserved terminal result: This lane uses real OpenTelemetry SDK/provider/exporter instances and two loopback HTTP OTLP services. A temporary evidence-only reporter over the same exact-head Source: openclaw/extensions/diagnostics-otel/src/service.otlp-export.test.ts Lines 418 to 556 in 3c246e1 The hot-path follow-up also removes private diagnostic payloads from synchronous preparation. Its regression test passes captured model content with an observable getter and proves preparation never reads it. Source: openclaw/src/infra/diagnostic-events.test.ts Lines 280 to 348 in 3c246e1 |
|
@clawsweeper re-review Exact head: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer disposition for exact head
No code changed after the exact-head review. |
|
Merged via squash.
|
* fix(diagnostics-otel): harness.run root span adopts diagnostic trace context Fall back to internalOrTrustedParentContext when there is no active tracked parent, so the openclaw.harness.run root span (and its whole OTel subtree) adopts the diagnostic traceId instead of minting a new OTel root. This lets spans propagated via the diagnostic traceparent (e.g. a2a-gateway a2a.call / downstream a2a.task) share one trace with the run internals. * fix(diagnostics-otel): propagate exported span context Co-authored-by: HughTang <[email protected]> * fix(diagnostics): break propagation import cycle * fix(diagnostics): preserve trace propagation contracts --------- Co-authored-by: Vincent Koc <[email protected]>
…cope * origin/main: (24 commits) fix(backup): skip transient gateway lock databases (openclaw#119782) test(agents): use canonical auth session fixtures (openclaw#119821) fix(memory): keep QMD file hints after stale docid misses (issue openclaw#113041) (openclaw#113515) test(doctor): align fast-path repair contracts (openclaw#119812) perf(agents): index subagent recovery ownership (openclaw#119793) fix(gateway): keep chat startup off catalog discovery (openclaw#119742) fix(test): keep TUI PTY suites in their owner lane (openclaw#119787) docs: correct dashboard auth precedence (openclaw#119785) docs: document control ui owner handoff fix: grant host-authorized control ui owner access fix(worktrees): preserve registered roots during orphan cleanup (openclaw#119709) fix(matrix): prevent shared client key collisions (openclaw#119667) fix(diagnostics-otel): propagate exported span context (openclaw#112283) fix(worker): isolate state observer failures (openclaw#117507) fix(qa): attest realized profile executions (openclaw#119761) fix(gateway): finish successful sessions after timestamp races (openclaw#119752) fix(agents): fence restart recovery lifecycle (openclaw#119776) fix(ui): preserve chat history and active run timing (openclaw#119729) improve(ollama): reduce inactive startup cost (openclaw#119745) improve(gateway): defer inactive plugin runtime imports (openclaw#119733) ...
Fixes #112278
Fixes #112486
Summary
The original patch correctly identified the split trace, but its diagnostic-parent fallback could attach
openclaw.harness.runto a span ID that no exporter emitted. This repair preserves HughTang's contribution while fixing the identifier mismatch at the trace translation and propagation owner boundary.IdGenerator.diagnostics-otelrecords the actual current/exported OpenTelemetrySpanContextwhen each run, model, or tool span is created.traceparentfrom that exporter-owned context, including plugin-owned and preloaded SDK copies.traceparent, so OpenClaw never advertises an unexported local parent.The four-commit contributor series is rebased onto exact main
397a60582a109489d7dd4f1be1136251c10dc1b9; final head is3c246e182d86a6c59ae8f3085a6ed6c60672e7b5. HughTang remains author ofef61be3fd3bc2cb7bec1fee7c7f19701a18e1b6a, and431b619db9b492d0aa11a228ba3c5d96e126e09cretains the HughTang co-author trailer.What Problem This Solves
OpenClaw diagnostic IDs and OpenTelemetry-generated span IDs are intentionally different identifier spaces. The previous outbound path serialized the diagnostic span ID while
diagnostics-otelexported a different OTel span ID. The original harness fallback unified trace IDs by inventing a remote parent from the diagnostic ID, but that parent still did not exist in exported spans.The canonical repair records the real exporter-owned context at span creation, carries it through the diagnostics owner boundary, and resolves it synchronously before outbound propagation. This fixes both the split trace in #112278 and the dangling parent in #112486 without changing OTel ID generation.
Evidence
Focused trusted-source tests:
Result: 443 tests passed across nine focused shards.
The real-SDK OTLP lane starts two HTTP OTLP services with real SDK/exporter instances and proves:
parentSpanIdresolves to an exported span;traceparenttrace/span IDs exactly equal the exportedopenclaw.model.callspan context.Static and packaged proof:
Changed-lane guards also passed formatting, plugin boundaries, dependency pins, script declarations, dead-export scans (production/full/script: zero), auth/webhook policy checks, and targeted type-aware lint. Repository search confirms no custom
IdGeneratororidGeneratorin the affected implementation.Fresh autoreview:
Result after the ClawSweeper hot-path correction: clean; no actionable P0-P2 findings, overall correctness
patch is correct, confidence 0.91.Exact-head hosted review and CI:
3c246e182d86a6c59ae8f3085a6ed6c60672e7b5with zero pending checks.Blacksmith/Testbox and native prepare:
not authenticated - run 'blacksmith auth login' first.blacksmith auth login --non-interactive --organization openclawdid not complete unattended.OPENCLAW_TESTBOX=1 scripts/pr prepare-run 112283completed successfully at2026-08-06T00:40:03Zinhosted_exact_or_recent_parentmode, verified the exact remote head and tree, and reused hosted exact-head gates.Repair Scope
diagnostics-otelexporter translation and service lifecycle.SpanContextpreparation/resolution through one typed synchronous bridge.traceparenton a bridge miss; no parallel custom-ID path was added.+261/-24, net+237, justified by the typed cross-SDK ownership boundary, exporter context mapping, and lifecycle-safe bridge.+522/-4, net+518.+11/-7, net+4.