fix(diagnostics): share event bus and log transport across module bundles#1
Open
triclambert wants to merge 1 commit intomainfrom
Open
fix(diagnostics): share event bus and log transport across module bundles#1triclambert wants to merge 1 commit intomainfrom
triclambert wants to merge 1 commit intomainfrom
Conversation
sreis
reviewed
Feb 17, 2026
1fda875 to
db63c03
Compare
…dles
The bundler gives the gateway and plugin-sdk their own copies of
diagnostic-events.ts, so emitDiagnosticEvent() and onDiagnosticEvent()
use separate listener Sets. Events emitted by the gateway never reach
the OTel plugin. Same issue affects the log transport registry in
logger.ts.
Fix: use globalThis[Symbol.for()] singletons for both registries,
matching the pattern already established in src/plugins/runtime.ts.
Also fix resolveOtelUrl() which used endpoint.includes('/v1/') to
decide whether to append the signal path. This breaks backends whose
base URL contains '/v1/' in a non-terminal position (e.g. Opik).
Replaced with endsWith checks against the three OTLP signal suffixes.
Closes openclaw#5190
Closes openclaw#18794
Closes openclaw#13783
db63c03 to
6f19cc0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
diagnostics-otelextension ships with every install but has never actually worked. Three bugs stack on top of each other to prevent any telemetry from reaching a collector.globalThis[Symbol.for()]singletons so plugin bundles share state with core. (2)resolveOtelUrl()usesendsWithagainst OTLP signal suffixes instead ofincludes("/v1/").Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Users who configure
diagnostics.otel.enabled: truewith an OTLP endpoint will now actually receive traces, metrics, and logs in their collector. Previously this configuration was silently non-functional.Security Impact (required)
NoNoNo(the OTel plugin already makes OTLP calls when enabled -- they just never fired due to the event bus bug)NoNoRepro + Verification
Environment
Steps
docker run -d -p 127.0.0.1:4318:4318 -p 127.0.0.1:16686:16686 jaegertracing/all-in-one:latestdiagnostics.enabled: true,diagnostics.otel.enabled: true,diagnostics.otel.endpoint: http://127.0.0.1:4318Expected
Traces appear in Jaeger at http://localhost:16686
Actual
Before fix: zero traces (confirmed via
ss -tn, matching openclaw#18794 repro).After fix: 3 traces with 3 spans appear in Jaeger.
Evidence
Unit tests: 18/18 pass (5 new tests added covering the exact bug scenarios).
Integration test output:
URL resolution test covers the openclaw#13783 case directly:
Human Verification (required)
/v1/in base path./v1/traces(no double-append),resetDiagnosticEventsForTest()correctly clears shared state, unsubscribe removes only the target listener.Compatibility / Migration
YesNoNoFailure Recovery (if this breaks)
globalThissingletons degrade gracefully -- if removed, behavior returns to the pre-fix state (events don't cross module boundaries, but nothing crashes).src/infra/diagnostic-events.ts,src/logging/logger.ts,extensions/diagnostics-otel/src/service.tsglobalThissymbols collide with another library (extremely unlikely withopenclaw.prefix), diagnostic events could leak to unintended listeners.Risks and Mitigations
globalThisshared state could cause test interference if tests in the same Vitest worker share the bus.resetDiagnosticEventsForTest()already exists for this purpose and now clears the shared bus. Existing tests already call it inbeforeEach. New test added to verify this works.AI disclosure: This PR was developed with AI assistance (Claude). All changes were manually reviewed, understood, and verified with live integration testing against Jaeger.