openclaw-otel
v1.0.0
Published
OpenTelemetry exporter for OpenClaw — ships diagnostic events as OTel logs, metrics, and traces with field shapes that work cleanly in Grafana / LGTM stacks.
Maintainers
Readme
openclaw-otel
OpenTelemetry exporter for OpenClaw. Ships diagnostic events from the OpenClaw runtime as OTel logs, metrics, and traces, with field shapes that work cleanly in Grafana and the broader LGTM (Loki / Tempo / Mimir) stack.
What it does
OpenClaw exposes a typed plugin API including a diagnostic event bus (onDiagnosticEvent). This plugin subscribes to that bus and emits the events as standard OpenTelemetry signals to an OTLP/HTTP endpoint.
You get:
- Logs with proper
severity_text/severity_numberper OTel spec,host.nameandservice.namepopulated, and trace context (trace_id/span_id) injected automatically when the log is emitted inside an active span. - Metrics following OTel semantic conventions —
_totalfor counters,_milliseconds/_seconds/_bytesfor unit-bearing metrics, no double-suffixed names, no high-cardinality auto-injected process labels. - Traces with W3C trace context propagation across operations, span names following
<namespace>.<operation>convention.
The data lands in your collector / backend with the labels Grafana expects out of the box — Log Levels dropdown populates, tracesToLogsV2 correlation works, service-graph view shows real edges.
Install
# In your OpenClaw npm workspace (typically ~/.openclaw/npm/):
npm install openclaw-otelEnable in openclaw.json:
{
"plugins": {
"entries": {
"openclaw-otel": { "enabled": true }
}
}
}Hot-reload OpenClaw or restart the gateway. The plugin discovers the OTLP endpoint from standard environment variables.
Configuration
Configure via environment variables (standard OTel conventions):
| Variable | Purpose | Example |
|---|---|---|
| OTEL_EXPORTER_OTLP_ENDPOINT | Base OTLP/HTTP endpoint | http://collector.example.com:4318 |
| OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | Override for traces only | http://traces.example.com:4318/v1/traces |
| OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | Override for metrics only | (similar) |
| OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | Override for logs only | (similar) |
| OTEL_SERVICE_NAME | Service identity | openclaw-prod-1 |
| OTEL_RESOURCE_ATTRIBUTES | Resource attributes (key=value, comma-separated) | host.name=host01,deployment.environment=prod |
The plugin also respects the per-plugin config block in openclaw.json if you prefer config over env. See openclaw.plugin.json for the schema.
Requirements
- Node.js 22.0 or newer
- OpenClaw 2026.5.3 or newer (peer dependency)
Field shape reference
Logs ship to your backend with at minimum:
service.name— your configured service identityservice.version— populated fromOTEL_RESOURCE_ATTRIBUTESif sethost.name— derived fromOTEL_RESOURCE_ATTRIBUTES, falling back toos.hostname()deployment.environment— fromOTEL_RESOURCE_ATTRIBUTES, default left to your collectorseverity_text(uppercase:INFO/WARN/ERROR) andseverity_number(OTel-canonical: 9 / 13 / 17)trace_idandspan_idwhen emitted within an active span scopecode.functionandcode.linenoreflecting the actual call site
Metrics ship with:
service.name,service.version,host.name,deployment.environmentas the resource scope- No
process.pid,process.command_args,process.executable_path, orhost.id— these are deliberately not promoted to labels (they multiply series on every restart) - Unit-suffixed names where applicable (
_milliseconds,_seconds,_bytes) without source-side double-suffixes
Traces ship with W3C trace context preserved across child spans and outbound RPCs.
Development
npm install
npm run typecheck
npm testSee CONTRIBUTING.md for the full development guide and CLAUDE.md for conventions when working with this repo via Claude Code or other AI agents.
License
MIT — see LICENSE.
