






















11---
2-summary: "Export OpenClaw diagnostics to any OpenTelemetry collector via the diagnostics-otel plugin (OTLP/HTTP)"
2+summary: "Export OpenClaw diagnostics to OpenTelemetry collectors or stdout JSONL via the diagnostics-otel plugin"
33title: "OpenTelemetry export"
44read_when:
55 - You want to send OpenClaw model usage, message flow, or session metrics to an OpenTelemetry collector
@@ -8,17 +8,19 @@ read_when:
88---
991010OpenClaw exports diagnostics through the official `diagnostics-otel` plugin
11-using **OTLP/HTTP (protobuf)**. Any collector or backend that accepts OTLP/HTTP
12-works without code changes. For local file logs and how to read them, see
13-[Logging](/logging).
11+using **OTLP/HTTP (protobuf)**. Logs can also be written as stdout JSONL for
12+container and sandbox log pipelines. Any collector or backend that accepts
13+OTLP/HTTP works without code changes. For local file logs and how to read them,
14+see [Logging](/logging).
14151516## How it fits together
16171718- **Diagnostics events** are structured, in-process records emitted by the
1819 Gateway and bundled plugins for model runs, message flow, sessions, queues,
1920 and exec.
2021- **`diagnostics-otel` plugin** subscribes to those events and exports them as
21- OpenTelemetry **metrics**, **traces**, and **logs** over OTLP/HTTP.
22+ OpenTelemetry **metrics**, **traces**, and **logs** over OTLP/HTTP. It can
23+ also mirror diagnostic log records to stdout JSONL.
2224- **Provider calls** receive a W3C `traceparent` header from OpenClaw's
2325 trusted model-call span context when the provider transport accepts custom
2426 headers. Plugin-emitted trace context is not propagated.
@@ -74,11 +76,13 @@ openclaw plugins enable diagnostics-otel
7476| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
7577| **Metrics** | Counters and histograms for token usage, cost, run duration, failover, skill usage, message flow, Talk events, queue lanes, session state/recovery, tool execution, oversized payloads, exec, and memory pressure. |
7678| **Traces** | Spans for model usage, model calls, harness lifecycle, skill usage, tool execution, exec, webhook/message processing, context assembly, and tool loops. |
77-| **Logs** | Structured `logging.file` records exported over OTLP when `diagnostics.otel.logs` is enabled; log bodies are withheld unless content capture is explicitly enabled. |
79+| **Logs** | Structured `logging.file` records exported over OTLP or stdout JSONL when `diagnostics.otel.logs` is enabled; log bodies are withheld unless content capture is explicitly enabled. |
78807981Toggle `traces`, `metrics`, and `logs` independently. Traces and metrics
8082default to on when `diagnostics.otel.enabled` is true. Logs default to off and
81-are exported only when `diagnostics.otel.logs` is explicitly `true`.
83+are exported only when `diagnostics.otel.logs` is explicitly `true`. Log export
84+defaults to OTLP; set `diagnostics.otel.logsExporter` to `stdout` for JSONL on
85+stdout, or `both` to send each diagnostic log record to OTLP and stdout.
82868387## Configuration reference
8488@@ -98,6 +102,7 @@ are exported only when `diagnostics.otel.logs` is explicitly `true`.
98102 traces: true,
99103 metrics: true,
100104 logs: true,
105+ logsExporter: "otlp", // otlp | stdout | both
101106 sampleRate: 0.2, // root-span sampler, 0.0..1.0
102107 flushIntervalMs: 60000, // metric export interval (min 1000ms)
103108 captureContent: {
@@ -176,6 +181,11 @@ on the public diagnostic event bus.
176181- **Logs:** OTLP logs respect `logging.level` (file log level). They use the
177182 diagnostic log-record redaction path, not console formatting. High-volume
178183 installs should prefer OTLP collector sampling/filtering over local sampling.
184+ Set `diagnostics.otel.logsExporter: "stdout"` when your platform already
185+ ships stdout/stderr to a log processor and you do not have an OTLP logs
186+ collector. Stdout records are one JSON object per line with `ts`, `signal`,
187+`service.name`, severity, body, redacted attributes, and trusted trace fields
188+ when available.
179189- **File-log correlation:** JSONL file logs include top-level `traceId`,
180190`spanId`, `parentSpanId`, and `traceFlags` when the log call carries a valid
181191 diagnostic trace context, which lets log processors join local log lines with
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。