Skip to content

feat: OM2 writer outputs names as provided, no suffix appending#1957

Open
zeitlinger wants to merge 3 commits intomainfrom
scrape-time-suffix-om2
Open

feat: OM2 writer outputs names as provided, no suffix appending#1957
zeitlinger wants to merge 3 commits intomainfrom
scrape-time-suffix-om2

Conversation

@zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Mar 17, 2026

Blocked by #1955 (core + OM1 writers)

Summary

The OM2 writer now uses expositionBaseName directly instead of
appending _total (counters) or unit suffixes. The _info suffix
is enforced per the OM2 spec (MUST). Part of #1942.

Key table

User provides OM1 OM2
Counter("events") events_total events
Counter("events_total") events_total events_total
Counter("req").unit(BYTES) req_bytes_total req_bytes
Counter("req_bytes").unit(BYTES) req_bytes_total req_bytes
Gauge("events_total") events_total events_total
Info("target") target_info target_info

PR stack

  1. Core model + OM1/protobuf writers (feat: move suffix handling to scrape time #1955)
  2. OTel preserve_names (independent)
  3. This PR — OM2 writer no-suffix

Test plan

  • mise run compile passes
  • OM2-specific tests verify no _total/unit suffix appending
  • _info suffix enforcement tested

Part of #1912.

@zeitlinger zeitlinger marked this pull request as ready for review March 17, 2026 10:31
@zeitlinger zeitlinger changed the base branch from scrape-time-suffix-core to main March 17, 2026 10:32
@zeitlinger zeitlinger force-pushed the scrape-time-suffix-om2 branch from 8a18993 to 23a0eb4 Compare March 18, 2026 08:00
Move metric name suffix handling (_total, _info, unit suffixes) from
creation time to scrape time. Each format writer now owns its suffix
conventions:

- OM1: smart-appends suffixes (skip if already present)
- Registry detects cross-format name collisions at registration time

Key changes:
- Remove all reserved metric name suffixes from PrometheusNaming
- Store original user-provided name separately from exposition base
  name in MetricMetadata (originalName vs expositionBaseName)
- Smart-append logic in OM1/protobuf writers for _total and _info
- Two-layer collision detection in PrometheusRegistry

Closes #1941
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
- Fix race condition: use putIfAbsent for atomic exposition name claiming
  with proper rollback on failure
- Extract claimExpositionNames/releaseExpositionNames for single rollback path
- Rename Info test methods to reflect that _info suffix is now allowed
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
The OM2 writer now uses expositionBaseName instead of appending
_total (counters) or unit suffixes. The _info suffix is enforced
per the OM2 spec (MUST). Tests updated to verify OM2-specific
output rather than asserting identity with OM1.
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger force-pushed the scrape-time-suffix-om2 branch from 23a0eb4 to 9fb30c8 Compare March 18, 2026 09:01
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.

1 participant