Repository navigation
Description
Summary
With diagnostics.otel.logs: true, OpenClaw exports log records over OTLP, but every LogRecord.body is the literal string "log" instead of the formatted message, and trace_id/span_id are empty on every record. The actual message is written to stdout/logToFile but never reaches the OTLP body — only metadata attributes (openclaw.subsystem, openclaw.log.level, code.function, code.lineno) survive.
Net effect: logs in any OTLP backend are both content-free (you can't read or search what happened) and uncorrelatable (no trace_id to join them to the trace/turn). This is distinct from #77391 (that's span attribute content / captureContent); this is about the OTLP logs signal.
Version note
Confirmed present through stable 2026.6.5 and pre-release 2026.6.10-alpha.1 — no merged PR appears to address it. (#70961 "attach trace context to otel logs" is already in-tree but doesn't populate trace_id here, because these logs are emitted outside an active span context — see #50291. #91256 addresses span content capture, not log-record bodies.)
Environment
- OpenClaw
2026.5.28(Docker); behavior reconfirmed against2026.6.5/2026.6.10-alpha.1 - Exporter: OTLP
http/protobuf→ an OpenTelemetry Collector (otlpreceiver,batchprocessor only, notransform/attributesprocessor) → an OTLP-compatible logs backend. The collector applies no log transformation, so the placeholder originates in OpenClaw. - Relevant config:
"diagnostics": { "enabled": true, "otel": { "enabled": true, "protocol": "http/protobuf", "serviceName": "<service-name>", "traces": true, "metrics": true, "logs": true, "sampleRate": 1.0, "flushIntervalMs": 10000 }}
Reproduction
openclaw config set diagnostics.otel.enabled true
openclaw config set diagnostics.otel.logs true
openclaw gateway restart --wait 30s
# trigger any error-level log (e.g. a run that hits a model fallback failure)Then query the OTLP logs backend (or inspect the collector's raw log capture).
Observed
A representative exported LogRecord (an ERROR-severity diagnostic log):
{
"body": "log",
"severityText": "ERROR",
"traceId": "",
"spanId": "",
"attributes": {
"openclaw.subsystem": "diagnostic",
"openclaw.log.level": "ERROR",
"openclaw.logger.parents": "openclaw",
"code.function": "logToFile",
"code.lineno": 179
}
}The corresponding stdout line carries the full, actionable content that is missing from the OTLP body — e.g. a diagnostic line of the form:
[diagnostic] <event>: ... outcome=error duration=<ms>ms error="<ErrorType>: <full reason>"
A backend query of body CONTAINS "<any word from the real message>" returns 0 rows — confirming the message text never reaches the OTLP record. The code.function: "logToFile" attribute suggests the OTLP log bridge captures the call site but emits a static "log" body rather than the rendered message.
Expected
LogRecord.bodyshould be the rendered log message (size-capped, optionally redacted) — the same content that goes to stdout/logToFile.- When a log is emitted within an active span context,
trace_id/span_idshould be populated so logs correlate to their trace/turn.
Impact
- OTLP log backends show only severity + subsystem + code location — the why of a failure is gone.
- With empty
trace_id, logs can't be joined to traces or to a turn, so observability tooling can't attach log context to a finding. - Combined with diagnostics.otel.captureContent.* is non-functional — runtime broadcast emits sanitized paramsSummary only #77391 (no span content) and Plugin Hooks: Missing trace context for observability (messageId, runId in all hooks, parentSpanId) #50291 (no trace context /
parentSpanId), a consumer reading only the telemetry backend cannot reconstruct what an agent did or why it failed — even though the detail exists locally.
Related
- diagnostics.otel.captureContent.* is non-functional — runtime broadcast emits sanitized paramsSummary only #77391 —
captureContent.*non-functional (span attribute content) - Plugin Hooks: Missing trace context for observability (messageId, runId in all hooks, parentSpanId) #50291 — Plugin Hooks missing trace context (
parentSpanId/runId)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 10, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 10, 2026, 6:13 AM ET / 10:13 UTC.
Summary
Keep open. Current main and v2026.6.5 still have the reported placeholder-body behavior, but log bodies are intentionally documented and tested behind a privacy/content-capture gate; changing that default or trusting logger trace context needs maintainer security/product direction.
Reproducibility: yes. for source-level reproduction: current source and tests show default OTLP log bodies are
"log", granular capture does not enable bodies, and untrusted trace context is not attached. I did not run a live OTLP collector reproduction in this read-only review.Next step
Needs maintainer security/product direction before implementation because the desired log-body default conflicts with the documented content-capture privacy gate and the trace part crosses the trusted diagnostic boundary.
Security
Needs attention: Any fix that exports rendered log bodies or broadens trusted trace context needs security review because it can send sensitive local log content and correlation identifiers to third-party collectors.
Review details
Best possible solution:
Maintainers should decide the privacy/trust boundary, then either reaffirm the current
captureContent: truepolicy or add a narrow documented log-body opt-in plus trusted trace-context propagation tests.Do we have a high-confidence way to reproduce the issue?
Yes for source-level reproduction: current source and tests show default OTLP log bodies are
"log", granular capture does not enable bodies, and untrusted trace context is not attached. I did not run a live OTLP collector reproduction in this read-only review.Is this the best way to solve the issue?
Unclear as filed. Exporting every rendered log body by default conflicts with the documented privacy model; the safer solution needs maintainer approval for either the existing broad capture setting, a narrower log-body opt-in, or a trusted logger-trace path.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against c84e52192063.
Label changes
Label justifications:
P2: This is a bounded diagnostics-otel observability problem, not a crash, data-loss, or urgent channel/runtime outage.impact:security: The requested body export changes sensitive log-content handling for external telemetry backends.impact:other: The concrete user impact is degraded OTLP log usefulness and trace correlation in observability tooling.Evidence reviewed
Security concerns:
extensions/diagnostics-otel/src/service.ts:1607The exporter currently gates rendered log bodies behind broad content capture; changing
diagnostics.otel.logsto export message bodies by default would broaden sensitive-data exposure beyond the documented opt-in.Confidence: 0.9
What I checked:
AGENTS.mdplus relevant scoped guides for extensions, agents, and docs; the security/defaults and plugin-boundary guidance affected the review outcome. (AGENTS.md:1, c84e52192063)recordLogRecordexports the rendered message only whenshouldCaptureOtelLogBody(contentCapturePolicy)is true; otherwise it emits the literal"log". (extensions/diagnostics-otel/src/service.ts:1607, c84e52192063)LogRecord.contextonly when diagnostic event metadata is trusted; ordinary logger-derivedlog.recordevents are not upgraded here. (extensions/diagnostics-otel/src/service.ts:1629, c84e52192063)captureContent: trueenableslogBodies, while object-form granular content capture leaveslogBodies: false. (extensions/diagnostics-otel/src/service.ts:460, c84e52192063)extensions/diagnostics-otel/src/service.test.ts:1322, c84e52192063)log.recordevent containing the sanitized message and any active or bound diagnostic trace, then emits it via the untrusted diagnostic event path. (src/logging/logger.ts:413, c84e52192063)Likely related people:
extensions/diagnostics-otel/src/service.ts,extensions/diagnostics-otel/src/service.test.ts)extensions/diagnostics-otel/src/service.ts,docs/gateway/opentelemetry.md)extensions/diagnostics-otel/src/service.ts,extensions/diagnostics-otel/src/service.test.ts)extensions/diagnostics-otel/src/service.ts,src/infra/diagnostic-events.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.joshavant commentedon Jun 12, 2026
Thanks @sinzin91 for the detailed report and repro notes.
#92276 fixed the trace/span correlation part of this issue. The root cause was that logger-derived diagnostic records could carry OpenClaw's active trace context, but the OTEL exporter treated those records as untrusted and therefore did not attach OTLP
trace_id/span_id. The fix now distinguishes OpenClaw-owned active trace context from caller-supplied trace objects, so logs emitted inside an active diagnostic trace scope are correlatable without allowing plugins or user-provided logger fields to spoof trace ancestry.We intentionally did not change the default
LogRecord.body: "log"behavior here. Exporting rendered log messages is still gated by the existing content-capture/privacy policy, so the resolved bug is the uncorrelatable OTLP logs portion. A narrower opt-in for OTLP log bodies would be a separate product/privacy decision.