René's URL Explorer Experiment


Title: Move suffix handling from creation time to scrape time (current release) · Issue #1941 · prometheus/client_java · GitHub

Open Graph Title: Move suffix handling from creation time to scrape time (current release) · Issue #1941 · prometheus/client_java

X Title: Move suffix handling from creation time to scrape time (current release) · Issue #1941 · prometheus/client_java

Description: Part of #1942 (full design rationale). Summary Today, Counter.Builder strips _total and PrometheusNaming rejects names ending with _total/_info at creation time. Then at exposition time, the format writers append _total back. This confli...

Open Graph Description: Part of #1942 (full design rationale). Summary Today, Counter.Builder strips _total and PrometheusNaming rejects names ending with _total/_info at creation time. Then at exposition time, the format...

X Description: Part of #1942 (full design rationale). Summary Today, Counter.Builder strips _total and PrometheusNaming rejects names ending with _total/_info at creation time. Then at exposition time, the format...

Opengraph URL: https://github.com/prometheus/client_java/issues/1941

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Move suffix handling from creation time to scrape time (current release)","articleBody":"\nPart of #1942 (full design rationale).\n\n## Summary\n\nToday, `Counter.Builder` strips `_total` and\n`PrometheusNaming` rejects names ending with `_total`/`_info`\nat creation time. Then at exposition time, the format writers\nappend `_total` back. This conflicts with OM2's principle\nthat metric names should not be modified.\n\nThe fix: stop rejecting these suffixes, and let each format\nwriter own its suffix conventions at scrape time.\n\n## Key table\n\nFormat writers adapt at scrape time.\n\n| User provides | OM1 | OTel | OTel preserve |\n|---|---|---|---|\n| `Counter(\"events\")` | `events_total` | `events` | `events` |\n| `Counter(\"events_total\")` | `events_total` | `events` | `events_total` |\n| `Counter(\"req_bytes\").unit(BYTES)` | `req_bytes_total` | name `req`, unit `By` | name `req_bytes`, unit `By` |\n| `Counter(\"req\").unit(BYTES)` | `req_bytes_total` | name `req`, unit `By` | name `req`, unit `By` |\n| `Gauge(\"connections\")` | `connections` | `connections` | `connections` |\n| `Gauge(\"events_total\")` | `events_total` | `events_total` | `events_total` |\n\n- Rows 1+2 cannot coexist — the registry detects the\n  collision and rejects the second registration.\n- OTel strips `_total` from **Counters** only (type-aware).\n  Gauges keep `_total`.\n- OTel preserve = name as provided.\n\n## Design decisions\n\n### `getPrometheusName()` stays unchanged\n\n`Counter.builder().name()` and `Info.builder().name()`\ncontinue to strip `_total`/`_info` so that\n`getPrometheusName()` returns the base name. This avoids a\npublic API break.\n\nThe original (unstripped) name is stored separately and used\nby format writers for smart-append logic.\n\n### Two-layer collision detection\n\n- **Primary key**: `prometheusName` (the stripped base name,\n  same as today). `Counter(\"events\")` and\n  `Counter(\"events_total\")` both map to `events`.\n- **Secondary index**: set of all OM1 names a metric would\n  produce. When registering, check for intersection with\n  already-reserved names. This catches cross-type collisions\n  like `Gauge(\"events_total\")` + `Counter(\"events\")` which\n  both produce `events_total` in OM1.\n\nThis is necessary because removing `_total`/`_info` from\nreserved suffixes allows `Gauge(\"events_total\")` for the\nfirst time. Without the secondary index, the cross-type\ncollision would go undetected.\n\n### `sanitizeMetricName` follows naturally\n\n`sanitizeMetricName()` strips whatever is in\n`RESERVED_METRIC_NAME_SUFFIXES`. Once all reserved suffixes\nare removed from that list, it stops stripping them\nautomatically. The contract (\"returns a name that passes\n`validateMetricName`\") is unchanged.\n\n## What to change\n\n### 1. Collision detection in `PrometheusRegistry`\n\nWhen registering a metric, compute the OM1 names it would\nproduce. Reject if any collide with an already-registered\nmetric's OM1 names.\n\nThis replaces today's blanket rejection of `_total` names\nwith precise collision checks:\n- `Gauge(\"foo_total\")` + `Histogram(\"foo\")` -> **no\n  collision** (OM1: `foo_total` vs\n  `foo_count`/`foo_sum`/`foo_bucket`). Fixes #1321.\n- `Gauge(\"foo_total\")` + `Counter(\"foo\")` -> **collision**\n  in OM1 (`foo_total` vs `foo_total`). Correctly rejected.\n- `Gauge(\"foo_count\")` + `Histogram(\"foo\")` -> **collision**\n  in OM1. Fixes the known gap documented in\n  `PrometheusNaming`.\n\nOM1 suffixes to check: `_total` (Counter), `_info` (Info),\n`_bucket`/`_count`/`_sum` (Histogram/Summary), `_created`\n(Counter/Histogram/Summary).\n\n### 2. Smart-append in OM1/protobuf writers\n\nChange `_total` appending from \"always append\" to \"append\nonly if not already present.\" Same for `_info`.\n\n### 3. Remove reserved suffixes + store original name\n\n- Remove all entries from `RESERVED_METRIC_NAME_SUFFIXES`\n  in `PrometheusNaming`\n- `validateMetricName()` stops rejecting these suffixes\n- `sanitizeMetricName()` stops stripping them\n  (automatically)\n- Store the original user-provided name alongside the\n  stripped `prometheusName` for use by format writers\n- `Counter.builder().name()` and `Info.builder().name()`\n  keep stripping (preserves `getPrometheusName()` behavior)\n\nCollision detection still checks OM1 structural names\n(`_total`, `_info`, `_bucket`, `_count`, `_sum`,\n`_created`) — this is about preventing ambiguous exposition\noutput, not about restricting user names.\n\n### 4. Scrape filter compatibility\n\n`scrape(Predicate\u003cString> includedNames)` tests both the\noriginal name and the `prometheusName` against the\npredicate, so filtering works regardless of which form the\ncaller uses.\n\n### 5. OTel exporter: `preserve_names` flag\n\nAdd `preserve_names` to `ExporterOpenTelemetryProperties`.\n\n#### `preserve_names` = `false` (default)\n\nLegacy behavior, kept for backward compatibility. The\nexporter transforms metric names:\n- Counter `_total` suffix is stripped\n  (`http_requests_total` -> `http_requests`)\n- Unit suffix is stripped from the name and moved to the\n  OTel unit metadata field\n  (`http_request_duration_seconds` -> name\n  `http_request_duration`, unit `s`)\n\nThis changes the names users defined, which can be confusing\nregardless of whether you come from an OTel or Prometheus\nbackground.\n\n#### `preserve_names` = `true`\n\nNames are passed through exactly as the user wrote them.\nNo appending, no stripping:\n- `Counter(\"events\")` -> `events`\n- `Counter(\"events_total\")` -> `events_total`\n- `Counter(\"req\").unit(BYTES)` -> name `req`, unit `By`\n- `Histogram(\"dur\").unit(SECONDS)` -> name `dur`, unit `s`\n\nUnit metadata is always set from `.unit()` if provided.\n\n`preserve_names` becomes the default in the next major\nrelease (#1943).\n\n## Backward compatibility\n\n- `Counter.builder().name(\"events\")` -> `prometheusName`\n  `events`, OM1: `events_total`, OTel: `events`.\n  **Same as today.**\n- `Counter.builder().name(\"events_total\")` ->\n  `prometheusName` `events`, OM1: `events_total`, OTel\n  legacy: `events`. **Same as today.**\n- `Gauge(\"events_total\")` -> OM1: `events_total`, OTel:\n  `events_total`. **New capability** (previously rejected).\n- `sanitizeMetricName(\"foo_total\")` -> `foo_total`\n  (was `foo`). **Fixes #1321.**\n- `sanitizeMetricName(\"foo_created\")` -> `foo_created`\n  (was `foo`). **Intentional** — all reserved suffixes\n  removed.\n- Simpleclient bridge: `sanitizeMetricName` returns\n  `events_total` -> goes into `CounterSnapshot` metadata ->\n  format writers smart-append correctly.\n  **Output unchanged.**\n\n## `disableSuffixAppending` not needed\n\nSuffix behavior is per-format, not a standalone config flag.\nOM2 config (#1939) should focus on `contentNegotiation`,\n`compositeValues`, `exemplarCompliance`,\n`nativeHistograms`. Suffix handling follows the format\nautomatically.","author":{"url":"https://github.com/zeitlinger","@type":"Person","name":"zeitlinger"},"datePublished":"2026-03-10T10:01:37Z","url":"https://github.com/prometheus/client_java/issues/1941"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:498fb501-7e2e-29c3-de84-4f23ba32c9fd
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB96C:E2D7:5CDDEF:7EB63A:6AFBC0AE
html-safe-noncee78f06d369ac5df504a34a4b2c6b42c39552a02ee2372b2bb6077efab5de53d1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTZDOkUyRDc6NUNEREVGOjdFQjYzQTo2QUZCQzBBRSIsInZpc2l0b3JfaWQiOiIyMTMzMjMzMTQ1ODc1MjUxMzc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac4002ae4f75e789f11f038d95ffaf878694180cf88f3d8d611f76938b4abdea62
hovercard-subject-tagissue:4050696340
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/prometheus/client_java/1941/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c3687b82c533a6923cf2a3d785137fee605708d0ebd0e322fa325ad0d5104cb7/prometheus/client_java/issues/1941
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c3687b82c533a6923cf2a3d785137fee605708d0ebd0e322fa325ad0d5104cb7/prometheus/client_java/issues/1941
og:image:altPart of #1942 (full design rationale). Summary Today, Counter.Builder strips _total and PrometheusNaming rejects names ending with _total/_info at creation time. Then at exposition time, the format...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamezeitlinger
hostnamegithub.com
expected-hostnamegithub.com
None2b2ef9c1578c18d8ed27027940544c958743213cf4461659f14d3ccdf51e162c
turbo-cache-controlno-preview
go-importgithub.com/prometheus/client_java git https://github.com/prometheus/client_java.git
octolytics-dimension-user_id3380462
octolytics-dimension-user_loginprometheus
octolytics-dimension-repository_id7997879
octolytics-dimension-repository_nwoprometheus/client_java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7997879
octolytics-dimension-repository_network_root_nwoprometheus/client_java
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasee4cce0e99cf61481a318ff12c2e8580153a6c7c6
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/prometheus/client_java/issues/1941#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fprometheus%2Fclient_java%2Fissues%2F1941
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fprometheus%2Fclient_java%2Fissues%2F1941
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=prometheus%2Fclient_java
Reloadhttps://github.com/prometheus/client_java/issues/1941
Reloadhttps://github.com/prometheus/client_java/issues/1941
Reloadhttps://github.com/prometheus/client_java/issues/1941
prometheushttps://github.com/prometheus
client_javahttps://github.com/prometheus/client_java
Codehttps://github.com/prometheus/client_java
Issues12 (12)https://github.com/prometheus/client_java/issues
Pull requests18 (18)https://github.com/prometheus/client_java/pulls
Actionshttps://github.com/prometheus/client_java/actions
Projectshttps://github.com/prometheus/client_java/projects
Security and qualityhttps://github.com/prometheus/client_java/security
Insightshttps://github.com/prometheus/client_java/pulse
https://github.com/prometheus/client_java
New issuehttps://github.com/login?return_to=https://github.com/prometheus/client_java/issues/1941
New issuehttps://github.com/login?return_to=https://github.com/prometheus/client_java/issues/1941
#1955https://github.com/prometheus/client_java/pull/1955
Move suffix handling from creation time to scrape time (current release)https://github.com/prometheus/client_java/issues/1941#top
#1955https://github.com/prometheus/client_java/pull/1955
https://github.com/zeitlinger
https://github.com/zeitlinger
zeitlingerhttps://github.com/zeitlinger
on Mar 10, 2026https://github.com/prometheus/client_java/issues/1941#issue-4050696340
#1942https://github.com/prometheus/client_java/issues/1942
Issue when using @Timed annotation with prometheus-metrics-instrumentation-dropwizard #1321https://github.com/prometheus/client_java/issues/1321
#1943https://github.com/prometheus/client_java/issues/1943
Issue when using @Timed annotation with prometheus-metrics-instrumentation-dropwizard #1321https://github.com/prometheus/client_java/issues/1321
#1939https://github.com/prometheus/client_java/pull/1939
zeitlingerhttps://github.com/zeitlinger
on Mar 10, 2026https://github.com/prometheus/client_java/issues/1941#event-23428890061
https://github.com/jaydeluca
jaydelucahttps://github.com/jaydeluca
on Mar 10, 2026https://github.com/prometheus/client_java/issues/1941#issuecomment-4034521835
#1943https://github.com/prometheus/client_java/issues/1943
https://github.com/zeitlinger
zeitlingerhttps://github.com/zeitlinger
on Mar 11, 2026https://github.com/prometheus/client_java/issues/1941#issuecomment-4036667431
zeitlingerhttps://github.com/zeitlinger
on Mar 13, 2026https://github.com/prometheus/client_java/issues/1941#event-23550704934
https://github.com/zeitlinger
zeitlingerhttps://github.com/zeitlinger
on Mar 14, 2026https://github.com/prometheus/client_java/issues/1941#issuecomment-4060438932
Move suffix handling from creation time to scrape time #1942https://github.com/prometheus/client_java/issues/1942
zeitlingerhttps://github.com/zeitlinger
on Mar 14, 2026https://github.com/prometheus/client_java/issues/1941#event-23573034060
feat: move suffix handling to scrape time with OTel preserve_nameshttps://github.com/prometheus/client_java/commit/e4a579de787fefc1a1b886dcd5addecd80492b6b
https://docs.github.com/articles/closing-issues-via-commit-messages
e4a579dhttps://github.com/prometheus/client_java/commit/e4a579de787fefc1a1b886dcd5addecd80492b6b
feat: move suffix handling to scrape time with OTel preserve_nameshttps://github.com/prometheus/client_java/commit/e95d408a821976b2632412d1adf99e53b554a8d5
https://docs.github.com/articles/closing-issues-via-commit-messages
e95d408https://github.com/prometheus/client_java/commit/e95d408a821976b2632412d1adf99e53b554a8d5
feat: move suffix handling to scrape timehttps://github.com/zeitlinger/client_java/commit/dfe5485239a33ab59e6082ebdeed4ce635344def
https://docs.github.com/articles/closing-issues-via-commit-messages
dfe5485https://github.com/zeitlinger/client_java/commit/dfe5485239a33ab59e6082ebdeed4ce635344def
feat: move suffix handling to scrape timehttps://github.com/prometheus/client_java/commit/07876612c15d71f413d4ab763cca6690b5086780
https://docs.github.com/articles/closing-issues-via-commit-messages
0787661https://github.com/prometheus/client_java/commit/07876612c15d71f413d4ab763cca6690b5086780
feat: move suffix handling to scrape time (#1955)https://github.com/prometheus/client_java/commit/5a5106c2ad46ad5e0c1c97d99b994e7626af18ee
#1955https://github.com/prometheus/client_java/pull/1955
https://docs.github.com/articles/closing-issues-via-commit-messages
5a5106chttps://github.com/prometheus/client_java/commit/5a5106c2ad46ad5e0c1c97d99b994e7626af18ee
zeitlingerhttps://github.com/zeitlinger
completedhttps://github.com/prometheus/client_java/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#1955https://github.com/prometheus/client_java/pull/1955
on Mar 20, 2026https://github.com/prometheus/client_java/issues/1941#event-23746743496
Sign up for freehttps://github.com/signup?return_to=https://github.com/prometheus/client_java/issues/1941
Sign in to commenthttps://github.com/login?return_to=https://github.com/prometheus/client_java/issues/1941
zeitlingerhttps://github.com/zeitlinger
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.