Skip to content

feat(diagnostics): configure OTEL metric name prefixes - #116687

Merged
jesse-merhi merged 5 commits into
mainfrom
jesse/diagnostics-otel-metric-prefix
Aug 2, 2026
Merged

jesse-merhi merged 5 commits into
mainfrom
jesse/diagnostics-otel-metric-prefix

Conversation

@jesse-merhi

@jesse-merhi jesse-merhi commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

New behavior

Operators can set diagnostics.otel.metricNamePrefix to replace the default openclaw. prefix on OpenClaw-owned metrics. This lets a shared telemetry backend receive names such as acme.tokens directly, without an OTLP rewrite step.

Configuration Token counter Run-duration histogram Semantic-convention metrics
Unset openclaw.tokens openclaw.run.duration_ms Unchanged
"acme." acme.tokens acme.run.duration_ms Unchanged
"" tokens run.duration_ms Unchanged
"acme.openclaw." acme.openclaw.tokens acme.openclaw.run.duration_ms Unchanged

The 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.usage and gen_ai.client.operation.duration are 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

  1. Set diagnostics.otel.metricNamePrefix to "acme." with diagnostics metrics enabled.
  2. Start the diagnostics OpenTelemetry service.
  3. Inspect the created instruments: acme.tokens and acme.run.duration_ms are present, openclaw.tokens is absent, and both gen_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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel size: M maintainer Maintainer-authored PR labels Jul 31, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 10:22 AM ET / 14:22 UTC.

ClawSweeper review

What this changes

This PR adds diagnostics.otel.metricNamePrefix, letting operators replace or remove the default openclaw. prefix on OpenClaw-owned OpenTelemetry metrics while preserving gen_ai.* semantic-convention names.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for explicit maintainer direction. It is a MEMBER-authored, maintainer-labeled feature that adds a durable diagnostics configuration contract; the implementation appears coherent and default-preserving, but accepting configurable metric namespaces is a product and compatibility choice rather than a routine bug fix.

Priority: P3
Reviewed head: b57ebf0f066199d407f51c5b4389ed8c8df55ccc
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation and focused coverage look sound, with merge readiness limited by the maintainer product decision on the new exported-metric contract.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a MEMBER-authored PR, so the external-contributor real-behavior-proof gate does not apply; its body nevertheless reports focused service-boundary and configuration-validation coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a MEMBER-authored PR, so the external-contributor real-behavior-proof gate does not apply; its body nevertheless reports focused service-boundary and configuration-validation coverage.
Evidence reviewed 5 items Current metric ownership boundary: Current main creates OpenClaw-owned instruments directly with the fixed openclaw. namespace, while the two gen_ai.client.* instruments are separately named. The proposed resolver at this owner boundary therefore targets the correct class of metrics without changing semantic-convention names.
Single service caller: Current main has one diagnostics-service call site for metric creation, so passing the configured prefix at service startup is a single canonical flow rather than duplicated downstream rewriting.
Configuration contract and validation: The PR adds the field to the strict diagnostics OTEL configuration shape, exported config type, help metadata, docs, and focused validation tests; its body also documents that changing the value intentionally renames affected metric series.
Findings None None.
Security None None.

How this fits together

The 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
Loading

Decision needed

Question Recommendation
Should OpenClaw support an operator-configurable namespace for OpenClaw-owned OpenTelemetry metric series, even though operators who change it must update their metric queries? Accept configurable namespaces: Merge the optional setting with openclaw. as the unchanged default and retain the explicit warning that changing it renames affected series.

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

  • Resolve merge risk (P1) - Opting into, changing, or removing the prefix intentionally renames all affected OpenClaw-owned metric series, so existing dashboards, alerts, and recording rules must be updated by the operator.
  • Resolve merge risk (P1) - The remaining blocker is product acceptance of a configurable exported-metric namespace as a supported diagnostics contract; green tests cannot settle that compatibility direction.
Agent review details

Security

None.

PR surface

Source +7, Tests +61, Docs +13. Total +81 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 103 96 +7
Tests 2 61 0 +61
Docs 1 13 0 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 177 96 +81

Review metrics

Metric Value Why it matters
Metric namespace configuration 1 optional configuration setting added The new setting can intentionally rename every OpenClaw-owned exported metric series in an existing deployment.

Merge-risk options

Maintainer options:

  1. Confirm the observability contract (recommended)
    Accept the deliberate metric-series rename behavior, retain the default, and merge after a maintainer records that this is a supported operator-facing configuration.
  2. Keep names immutable
    Pause or close the feature if stable OpenClaw-owned metric names are the preferred long-term operator contract.

Technical review

Best 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 openclaw. as the unset default.

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.

Labels

Label justifications:

  • P3: This is an optional diagnostics feature with an unchanged default, not an urgent user-facing regression.
  • merge-risk: 🚨 compatibility: Operators who enable or later change the setting must update queries for dashboards, alerts, and recording rules that use the former metric names.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a MEMBER-authored PR, so the external-contributor real-behavior-proof gate does not apply; its body nevertheless reports focused service-boundary and configuration-validation coverage.

Evidence

What I checked:

  • Current metric ownership boundary: Current main creates OpenClaw-owned instruments directly with the fixed openclaw. namespace, while the two gen_ai.client.* instruments are separately named. The proposed resolver at this owner boundary therefore targets the correct class of metrics without changing semantic-convention names. (extensions/diagnostics-otel/src/service-metrics.ts:9, 8404f5fee373)
  • Single service caller: Current main has one diagnostics-service call site for metric creation, so passing the configured prefix at service startup is a single canonical flow rather than duplicated downstream rewriting. (extensions/diagnostics-otel/src/service.ts:260, 9bb7a3c8fd7a)
  • Configuration contract and validation: The PR adds the field to the strict diagnostics OTEL configuration shape, exported config type, help metadata, docs, and focused validation tests; its body also documents that changing the value intentionally renames affected metric series. (src/config/zod-schema.root-shape.ts:32, b57ebf0f0661)
  • Area provenance: Blame and file history attribute the current diagnostics metric service and adjacent diagnostics configuration surface to Peter Steinberger's recent merged work, making that history the strongest current-main ownership signal. (extensions/diagnostics-otel/src/service-metrics.ts:9, 8404f5fee373)
  • Current-main comparison: The PR head is not an ancestor of current origin/main; the item has not already landed and no release provenance can support an implemented-on-main close. (b57ebf0f0661)

Likely related people:

  • Peter Steinberger: Current service-metrics.ts and the adjacent diagnostics OTEL configuration block trace to this recent merged commit, which is the strongest available ownership signal for the existing behavior. (role: recent diagnostics metrics contributor; confidence: high; commits: 8404f5fee373; files: extensions/diagnostics-otel/src/service-metrics.ts, extensions/diagnostics-otel/src/service.ts, src/config/zod-schema.root-shape.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record a maintainer decision accepting or rejecting configurable OpenTelemetry metric namespaces before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-31T07:14:42.500Z sha acf7467 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-31T07:19:41.277Z sha acf7467 :: found issues before merge. :: [P2] Validate metric prefixes before creating instruments
  • reviewed 2026-07-31T07:54:34.263Z sha acf7467 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T05:55:41.083Z sha acf7467 :: found issues before merge. :: [P2] Validate metric prefixes before creating instruments
  • reviewed 2026-08-01T11:12:56.233Z sha bc81e6b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T15:06:52.694Z sha bc81e6b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T15:30:20.752Z sha bc81e6b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-02T14:15:08.591Z sha b57ebf0 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 31, 2026
@jesse-merhi
jesse-merhi marked this pull request as ready for review July 31, 2026 06:29
Copilot AI review requested due to automatic review settings July 31, 2026 06:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 31, 2026
@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 31, 2026
@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 31, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 31, 2026
@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 1, 2026
@jesse-merhi jesse-merhi self-assigned this Aug 2, 2026
@jesse-merhi
jesse-merhi merged commit 0181ba6 into main Aug 2, 2026
256 of 258 checks passed
@jesse-merhi
jesse-merhi deleted the jesse/diagnostics-otel-metric-prefix branch August 2, 2026 14:29
@jesse-merhi

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 2, 2026
* 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)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
* 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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: diagnostics-otel Extension: diagnostics-otel gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants