Repository navigation
feat(diagnostics): configure OTEL metric name prefixes - #116687
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 10:22 AM ET / 14:22 UTC. ClawSweeper reviewWhat this changesThis PR adds Merge readinessKeep this PR open for explicit maintainer direction. It is a MEMBER-authored, Priority: P3 Review scores
Verification
How this fits togetherThe bundled diagnostics OpenTelemetry plugin reads gateway diagnostics configuration, creates OpenClaw metric instruments, and exports those series to an OTLP backend. The proposed setting changes the naming transformation at instrument creation, affecting dashboards and alerts that query those exported names. flowchart LR
A[Gateway diagnostics configuration] --> B[Diagnostics OpenTelemetry plugin]
B --> C[Metric name transformation]
C --> D[OpenClaw-owned instruments]
B --> E[Semantic-convention instruments]
D --> F[OTLP collector and dashboards]
E --> F
Decision needed
Why: This is a new persistent configuration and observability contract, not a repair to established broken behavior. The PR is also explicitly marked for maintainer handling, so automated review should not choose the permanent product direction. Before merge
Agent review detailsSecurityNone. PR surfaceSource +7, Tests +61, Docs +13. Total +81 across 9 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: If maintainers accept configurable exported namespaces, merge the default-preserving setting with its validation and migration guidance, keeping semantic-convention metric names unchanged and retaining Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds a new optional diagnostics capability rather than fixing a reported failing path. The supplied PR evidence includes focused service-boundary cases for unset, replacement, empty, and nested prefixes, but no failing-current-main reproduction is expected for a feature. Is this the best way to solve the issue? Unclear pending maintainer direction. Applying the prefix at the diagnostics plugin's instrument-creation boundary is the narrowest implementation shape because current main has one caller and distinguishes OpenClaw-owned from semantic-convention metrics, but the new exported-namespace contract needs human acceptance. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9bb7a3c8fd7a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (13 earlier review cycles; latest 8 shown)
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
/clawsweeper re-review |
|
/clawsweeper re-review |
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* origin/main: fix(sqlite): skip slow-lock diagnostic when busyTimeoutMs is zero (#115990) fix(canvas): serve Content-Length on Canvas document HEAD responses (#117964) fix(workboard): diagnose archived cards still in an active status (#116359) (#117290) feat(diagnostics): configure OTEL metric name prefixes (#116687) fix(ui): respect UTC when filtering pending usage sessions (#118004)
* feat(diagnostics): support OTEL metric name prefixes * feat(diagnostics): replace the default metric prefix * docs(diagnostics): explain metric prefix migration impact * fix(diagnostics): validate metric name prefixes
* origin/main: fix(sqlite): skip slow-lock diagnostic when busyTimeoutMs is zero (openclaw#115990) fix(canvas): serve Content-Length on Canvas document HEAD responses (openclaw#117964) fix(workboard): diagnose archived cards still in an active status (openclaw#116359) (openclaw#117290) feat(diagnostics): configure OTEL metric name prefixes (openclaw#116687) fix(ui): respect UTC when filtering pending usage sessions (openclaw#118004)
New behavior
Operators can set
diagnostics.otel.metricNamePrefixto replace the defaultopenclaw.prefix on OpenClaw-owned metrics. This lets a shared telemetry backend receive names such asacme.tokensdirectly, without an OTLP rewrite step.openclaw.tokensopenclaw.run.duration_ms"acme."acme.tokensacme.run.duration_ms""tokensrun.duration_ms"acme.openclaw."acme.openclaw.tokensacme.openclaw.run.duration_msThe setting is optional and includes the separator. Empty removes the prefix entirely; non-empty values must start with an ASCII letter and contain at most 128 OpenTelemetry-compatible characters. Standard names such as
gen_ai.client.token.usageandgen_ai.client.operation.durationare never prefixed.Product decision and migration impact
This PR intentionally accepts configurable exported metric namespaces as a supported diagnostics contract. The default remains
openclaw., so existing deployments do not change. Operators that enable or later change the setting must update dashboards, alerts, and recording rules that query the previous metric names.How to verify
diagnostics.otel.metricNamePrefixto"acme."with diagnostics metrics enabled.acme.tokensandacme.run.duration_msare present,openclaw.tokensis absent, and bothgen_ai.client.*instruments retain their canonical names.The focused diagnostics test exercises these steps through the service boundary for the unset, replacement, and explicitly nested configurations.
Checks
node scripts/run-vitest.mjs extensions/diagnostics-otel/src/service.test.ts— 117 tests passed, including the four naming scenarios above.node scripts/run-vitest.mjs src/config/config-misc.test.ts— 90 tests passed; valid prefix fragments are accepted and invalid characters, leading characters, lengths, and types are rejected.pnpm docs:check-mdx— 764 documentation files passed.node scripts/check-changed.mjs --base origin/main— full changed gate passed on Linux, including typechecks, lint, generated config metadata, plugin boundaries, formatting, and repository guards.Implementation notes
Prefix replacement happens when the diagnostics plugin creates its OpenClaw-owned instruments. Existing names remain the default, so this adds one optional config surface without requiring a migration or doctor repair.