Skip to content

diagnostics.otel log export sets every LogRecord body to the literal "log" and omits trace_id/span_id — OTLP logs are content-free and uncorrelatable #91865

Closed

Description

@sinzin91

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 against 2026.6.5 / 2026.6.10-alpha.1
  • Exporter: OTLP http/protobuf → an OpenTelemetry Collector (otlp receiver, batch processor only, no transform/attributes processor) → 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.body should 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_id should be populated so logs correlate to their trace/turn.

Impact

Related

Activity

  1. clawsweeper commented on Jun 10, 2026

    @clawsweeper
    Contributor

    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: true policy 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:

    • Exporting rendered log bodies by default would change the documented privacy posture and could send sensitive local logs to external OTLP collectors.
    • Trace correlation for logger-derived records depends on the trusted/untrusted diagnostic event boundary, so a one-line exporter change could either keep the issue unsolved or weaken spoofing protections.

    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:

    • [medium] Avoid default raw log body export — extensions/diagnostics-otel/src/service.ts:1607
      The exporter currently gates rendered log bodies behind broad content capture; changing diagnostics.otel.logs to export message bodies by default would broaden sensitive-data exposure beyond the documented opt-in.
      Confidence: 0.9

    What I checked:

    Likely related people:

    • vincentkoc: Authored the merged diagnostics PR that attached trusted diagnostic trace context to OTEL logs and appears frequently in diagnostics-otel history. (role: related trace-context contributor; confidence: high; commits: 8fade9df27a9, e8ea1fe99d81; files: extensions/diagnostics-otel/src/service.ts, extensions/diagnostics-otel/src/service.test.ts)
    • amknight: Recently merged trusted-channel diagnostics-otel content capture work adjacent to the requested log-body/content-capture behavior. (role: recent adjacent diagnostics contributor; confidence: medium; commits: bf9588381271; files: extensions/diagnostics-otel/src/service.ts, docs/gateway/opentelemetry.md)
    • brandonwise: Changed diagnostics-otel log export redaction for sensitive data, directly relevant to any decision to export rendered log bodies. (role: adjacent security contributor; confidence: medium; commits: 7fab4d128aeb; files: extensions/diagnostics-otel/src/service.ts, extensions/diagnostics-otel/src/service.test.ts)
    • Peter Steinberger: Introduced the original diagnostics events and OTEL exporter surface that this issue builds on. (role: feature introducer; confidence: medium; commits: 5c4079f66cc0; files: extensions/diagnostics-otel/src/service.ts, src/infra/diagnostic-events.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.
    impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.
    on Jun 10, 2026
  3. self-assigned this
    on Jun 11, 2026
  4. joshavant commented on Jun 12, 2026

    @joshavant
    Collaborator

    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.

  5. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions