fix(diagnostics-otel): support preloaded sdk mode#71450
Conversation
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Telemetry export policy bypass when `OPENCLAW_OTEL_PRELOADED=1` uses global OpenTelemetry providers
DescriptionIn Impact:
Vulnerable behavior: const sdkPreloaded = hasPreloadedOtelSdk();
...
if (!sdkPreloaded && (tracesEnabled || metricsEnabled)) {
// configure OTLP exporters with endpoint/headers and start NodeSDK
} else if (sdkPreloaded && (tracesEnabled || metricsEnabled)) {
ctx.logger.info("diagnostics-otel: using preloaded OpenTelemetry SDK");
}
const meter = metrics.getMeter("openclaw");
const tracer = trace.getTracer("openclaw");RecommendationHarden preloaded-SDK mode to prevent unintentional routing of telemetry to untrusted exporters:
Example (gating by config): const sdkPreloaded = process.env.OPENCLAW_OTEL_PRELOADED === "1";
const allowPreloaded = otel.allowPreloadedSdk === true;
if (sdkPreloaded && !allowPreloaded) {
ctx.logger.warn("diagnostics-otel: preloaded SDK requested but not allowed by config");
return;
}Analyzed PR: #71450 at commit Last updated on: 2026-04-25T06:54:16Z |
Greptile SummaryThis PR adds Confidence Score: 4/5PR is safe to merge; only a minor changelog attribution issue was found. The implementation is correct and test coverage is thorough. The only finding is a P2 style issue: the CHANGELOG entry references the parent PR #70424 rather than this PR #71450. CHANGELOG.md — wrong PR reference in the new entry. Prompt To Fix All With AIThis is a comment left during a code review.
Path: CHANGELOG.md
Line: 9
Comment:
**Wrong PR reference in changelog entry**
The CHANGELOG entry credits `#70424` (the original parent PR) rather than this PR (`#71450`). Changelog entries should reference the PR that actually merges the change into the main branch; linking to the parent PR makes it harder to trace the merge history.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(diagnostics-otel): support preloaded..." | Re-trigger Greptile |
|
|
||
| ### Changes | ||
|
|
||
| - Diagnostics/OTEL: support `OPENCLAW_OTEL_PRELOADED=1` so the plugin can reuse an already-registered OpenTelemetry SDK while keeping OpenClaw diagnostic listeners wired. (#70424) Thanks @jlapenna. |
There was a problem hiding this comment.
Wrong PR reference in changelog entry
The CHANGELOG entry credits #70424 (the original parent PR) rather than this PR (#71450). Changelog entries should reference the PR that actually merges the change into the main branch; linking to the parent PR makes it harder to trace the merge history.
Prompt To Fix With AI
This is a comment left during a code review.
Path: CHANGELOG.md
Line: 9
Comment:
**Wrong PR reference in changelog entry**
The CHANGELOG entry credits `#70424` (the original parent PR) rather than this PR (`#71450`). Changelog entries should reference the PR that actually merges the change into the main branch; linking to the parent PR makes it harder to trace the merge history.
How can I resolve this? If you propose a fix, please make it concise.- Two Diagnostics/OTEL Changes entries credited issue #70424 (jlapenna's open meta-tracing proposal) as the PR ref. The actual implementing PRs landed as #71451 (exec-process telemetry) and #71450 (preloaded SDK mode), both authored by @vincentkoc — corrected. - Telegram/webhook fix had no Thanks credit. Issue #71392 reporter @joelforsberg46-source identified the delivery-retry behaviour, so credit them on the entry.
… tool-result pruning entries Three entries were missing co-credits I should have preserved: - Diagnostics/OTEL exec-process spans (#71451): @vincentkoc implemented, but @jlapenna's #70424 proposed the broader tracing work this entry builds on. Now credits both. - Diagnostics/OTEL preloaded SDK (#71450): same pattern — credits @vincentkoc and @jlapenna. - Agents/tool-result pruning (#51267): @cgdusek's PR explicitly built on prior work in #39331 by @alvinttang and #34980 by @coffeexcoin. Now credits all three.
- Two Diagnostics/OTEL Changes entries credited issue openclaw#70424 (jlapenna's open meta-tracing proposal) as the PR ref. The actual implementing PRs landed as openclaw#71451 (exec-process telemetry) and openclaw#71450 (preloaded SDK mode), both authored by @vincentkoc — corrected. - Telegram/webhook fix had no Thanks credit. Issue openclaw#71392 reporter @joelforsberg46-source identified the delivery-retry behaviour, so credit them on the entry.
… tool-result pruning entries Three entries were missing co-credits I should have preserved: - Diagnostics/OTEL exec-process spans (openclaw#71451): @vincentkoc implemented, but @jlapenna's openclaw#70424 proposed the broader tracing work this entry builds on. Now credits both. - Diagnostics/OTEL preloaded SDK (openclaw#71450): same pattern — credits @vincentkoc and @jlapenna. - Agents/tool-result pruning (openclaw#51267): @cgdusek's PR explicitly built on prior work in openclaw#39331 by @alvinttang and openclaw#34980 by @coffeexcoin. Now credits all three.
- Two Diagnostics/OTEL Changes entries credited issue openclaw#70424 (jlapenna's open meta-tracing proposal) as the PR ref. The actual implementing PRs landed as openclaw#71451 (exec-process telemetry) and openclaw#71450 (preloaded SDK mode), both authored by @vincentkoc — corrected. - Telegram/webhook fix had no Thanks credit. Issue openclaw#71392 reporter @joelforsberg46-source identified the delivery-retry behaviour, so credit them on the entry.
… tool-result pruning entries Three entries were missing co-credits I should have preserved: - Diagnostics/OTEL exec-process spans (openclaw#71451): @vincentkoc implemented, but @jlapenna's openclaw#70424 proposed the broader tracing work this entry builds on. Now credits both. - Diagnostics/OTEL preloaded SDK (openclaw#71450): same pattern — credits @vincentkoc and @jlapenna. - Agents/tool-result pruning (openclaw#51267): @cgdusek's PR explicitly built on prior work in openclaw#39331 by @alvinttang and openclaw#34980 by @coffeexcoin. Now credits all three.
- Two Diagnostics/OTEL Changes entries credited issue openclaw#70424 (jlapenna's open meta-tracing proposal) as the PR ref. The actual implementing PRs landed as openclaw#71451 (exec-process telemetry) and openclaw#71450 (preloaded SDK mode), both authored by @vincentkoc — corrected. - Telegram/webhook fix had no Thanks credit. Issue openclaw#71392 reporter @joelforsberg46-source identified the delivery-retry behaviour, so credit them on the entry.
… tool-result pruning entries Three entries were missing co-credits I should have preserved: - Diagnostics/OTEL exec-process spans (openclaw#71451): @vincentkoc implemented, but @jlapenna's openclaw#70424 proposed the broader tracing work this entry builds on. Now credits both. - Diagnostics/OTEL preloaded SDK (openclaw#71450): same pattern — credits @vincentkoc and @jlapenna. - Agents/tool-result pruning (openclaw#51267): @cgdusek's PR explicitly built on prior work in openclaw#39331 by @alvinttang and openclaw#34980 by @coffeexcoin. Now credits all three.
- Two Diagnostics/OTEL Changes entries credited issue openclaw#70424 (jlapenna's open meta-tracing proposal) as the PR ref. The actual implementing PRs landed as openclaw#71451 (exec-process telemetry) and openclaw#71450 (preloaded SDK mode), both authored by @vincentkoc — corrected. - Telegram/webhook fix had no Thanks credit. Issue openclaw#71392 reporter @joelforsberg46-source identified the delivery-retry behaviour, so credit them on the entry.
… tool-result pruning entries Three entries were missing co-credits I should have preserved: - Diagnostics/OTEL exec-process spans (openclaw#71451): @vincentkoc implemented, but @jlapenna's openclaw#70424 proposed the broader tracing work this entry builds on. Now credits both. - Diagnostics/OTEL preloaded SDK (openclaw#71450): same pattern — credits @vincentkoc and @jlapenna. - Agents/tool-result pruning (openclaw#51267): @cgdusek's PR explicitly built on prior work in openclaw#39331 by @alvinttang and openclaw#34980 by @coffeexcoin. Now credits all three.
- Two Diagnostics/OTEL Changes entries credited issue openclaw#70424 (jlapenna's open meta-tracing proposal) as the PR ref. The actual implementing PRs landed as openclaw#71451 (exec-process telemetry) and openclaw#71450 (preloaded SDK mode), both authored by @vincentkoc — corrected. - Telegram/webhook fix had no Thanks credit. Issue openclaw#71392 reporter @joelforsberg46-source identified the delivery-retry behaviour, so credit them on the entry.
… tool-result pruning entries Three entries were missing co-credits I should have preserved: - Diagnostics/OTEL exec-process spans (openclaw#71451): @vincentkoc implemented, but @jlapenna's openclaw#70424 proposed the broader tracing work this entry builds on. Now credits both. - Diagnostics/OTEL preloaded SDK (openclaw#71450): same pattern — credits @vincentkoc and @jlapenna. - Agents/tool-result pruning (openclaw#51267): @cgdusek's PR explicitly built on prior work in openclaw#39331 by @alvinttang and openclaw#34980 by @coffeexcoin. Now credits all three.
Summary
OPENCLAW_OTEL_PRELOADED=1in diagnostics-otel so hosts with an existing global OpenTelemetry SDK do not get a second plugin-owned NodeSDKdiagnostics.otel.tracesis disabledExtracted from the safe preloaded-SDK portion of #70424 without taking the direct agent-runtime span instrumentation, root dependency, Dockerfile, or preload script changes.
Validation
pnpm test extensions/diagnostics-otel/src/service.test.tsgit diff --check HEAD~1..HEAD