feat(metrics): add configurable system prefix and separator#6445
Merged
Conversation
…histogram macros
Replace the `__key_name!` macro with a `const fn __sep()` + `concatcp!`
approach so that both string literals and const paths (like `SYSTEM`)
work uniformly as the system prefix.
Each metric macro now accepts an optional `system:` argument. When
omitted, the system defaults to `$crate::SYSTEM` ("quickwit"). All
existing call sites continue to work without changes.
Co-authored-by: Cursor <cursoragent@cursor.com>
3374a2c to
437b81f
Compare
Add explicit counter, gauge, and histogram tests for custom, default, empty, and const system/subsystem combinations, and assert emitted values for each case. Co-authored-by: Cursor <cursoragent@cursor.com>
Extend counter, gauge, and histogram base declaration macros to accept a configurable separator while defaulting to SEPARATOR, and add key-name tests for custom separators. Co-authored-by: Cursor <cursoragent@cursor.com>
Show how to override the default metric name separator with "." in the example service and print the resulting dotted metric key. Co-authored-by: Cursor <cursoragent@cursor.com>
shuheiktgw
approved these changes
May 19, 2026
PSeitz-dd
approved these changes
May 20, 2026
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74644e2f11
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
trinity-1686a
approved these changes
May 20, 2026
Add subsystem+separator macro arms for counter, gauge, and histogram so callers can customize separators without explicitly overriding system, and cover this with key-name tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
system:support tocounter!,gauge!, andhistogram!so callers can override the system prefix in metric key names.separator:support for base metric declarations in the same three macros.SYSTEM("quickwit") andSEPARATOR("_") when omitted.Metric key name composition
Separators are inserted only between non-empty segments.
Examples:
system: "quickwit", subsystem: "http", separator: "_"=>quickwit_http_requests_totalsystem: "myapp", subsystem: "http", separator: "."=>myapp.http.requests_totalsystem: "", subsystem: "http"=>http_requests_totalMacro signatures (base declarations)
Test plan
cargo test -p quickwit-metrics".") for counter/gauge/histogramMade with Cursor