Skip to content

feat(metrics): add configurable system prefix and separator#6445

Merged
Mallets merged 9 commits into
mainfrom
mallets/metrics-configurable-system
May 20, 2026
Merged

feat(metrics): add configurable system prefix and separator#6445
Mallets merged 9 commits into
mainfrom
mallets/metrics-configurable-system

Conversation

@Mallets
Copy link
Copy Markdown
Contributor

@Mallets Mallets commented May 19, 2026

Summary

  • Add optional system: support to counter!, gauge!, and histogram! so callers can override the system prefix in metric key names.
  • Add configurable separator: support for base metric declarations in the same three macros.
  • Keep full backward compatibility by defaulting to SYSTEM ("quickwit") and SEPARATOR ("_") when omitted.
  • Add key-name coverage tests for system/subsystem combinations and custom separators across counter/gauge/histogram, plus regression tests for single-evaluation semantics.

Metric key name composition

{system}{separator}{subsystem}{separator}{name}

Separators are inserted only between non-empty segments.
Examples:

  • system: "quickwit", subsystem: "http", separator: "_" => quickwit_http_requests_total
  • system: "myapp", subsystem: "http", separator: "." => myapp.http.requests_total
  • system: "", subsystem: "http" => http_requests_total

Macro signatures (base declarations)

// Explicit system/subsystem with optional custom separator.
counter!(
    name: "requests_total",
    description: "...",
    system: "myapp",
    subsystem: "http",
    separator: ".",
);

// Defaults: system = SYSTEM ("quickwit"), separator = SEPARATOR ("_").
counter!(name: "requests_total", description: "...", subsystem: "http");

// Same behavior for gauge! and histogram!.

Test plan

  • cargo test -p quickwit-metrics
  • key-name tests cover custom/default/empty/const system cases for counter/gauge/histogram
  • key-name tests cover custom separator (".") for counter/gauge/histogram
  • regression tests assert inline parent label expressions are evaluated once in counter/gauge/histogram

Made with Cursor

…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>
@Mallets Mallets force-pushed the mallets/metrics-configurable-system branch from 3374a2c to 437b81f Compare May 19, 2026 13:43
@Mallets Mallets marked this pull request as ready for review May 19, 2026 13:45
@Mallets Mallets requested a review from a team as a code owner May 19, 2026 13:45
Mallets and others added 2 commits May 19, 2026 16:06
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>
@Mallets Mallets changed the title feat(metrics): add configurable system prefix to metric macros feat(metrics): add configurable system prefix and separator May 19, 2026
Mallets and others added 3 commits May 19, 2026 17:10
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>
@Mallets Mallets self-assigned this May 19, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread quickwit/quickwit-metrics/src/counter.rs
Mallets and others added 2 commits May 20, 2026 09:47
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>
@Mallets Mallets enabled auto-merge (squash) May 20, 2026 08:00
@Mallets Mallets merged commit dd6442e into main May 20, 2026
9 checks passed
@Mallets Mallets deleted the mallets/metrics-configurable-system branch May 20, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants