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

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

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