Skip to content

fix(config): keep metric name case in metric-specific properties - #2588

Merged
zeitlinger merged 1 commit into
prometheus:mainfrom
Tanishq-Choudhary:metric-name-case-in-properties
Oct 23, 2026
Merged

zeitlinger merged 1 commit into
prometheus:mainfrom
Tanishq-Choudhary:metric-name-case-in-properties

Conversation

@Tanishq-Choudhary

Copy link
Copy Markdown
Contributor

Problem

Since 1.5.0, metric-specific properties are ignored when the metric name has an uppercase letter. With

io.prometheus.metrics.myLatency.histogram_classic_upper_bounds=.005, .01, .015

a histogram named myLatency keeps the default buckets. normalizePropertyKey(), added in #1828 to accept camelCase property names, lowercases the whole key including the metric name. The settings are stored under my_latency, while StatefulMetric looks them up as myLatency and gets null. There is no "Unknown property" error because the key was consumed. In 1.4.3 the same config (with histogramClassicUpperBounds) applies to myLatency; I ran both versions to check. An automated review comment on #1828 pointed this out, but metric names are still lowercased on main.

Fix

In io.prometheus.metrics.<metric>.<property> keys only the property name is normalized, so io.prometheus.metrics.myLatency.histogramNativeOnly becomes io.prometheus.metrics.myLatency.histogram_native_only. Default metric keys and exporter keys are normalized as before, and environment variables are not affected.

A key written with uppercase letters for a lowercase metric, like io.prometheus.metrics.My_metric.histogram_native_only for my_metric, no longer applies. That matches 1.4.x.

How tested

New PrometheusPropertiesLoaderTest.metricSpecificPropertiesShouldKeepMetricNameCase fails on main with a NullPointerException because getMetricProperties("myLatency") returns null, and passes with this change. I also added a case to normalizePropertyKeyShouldConvertCamelCaseToSnakeCase. prometheus-metrics-config (62 tests, coverage check) and prometheus-metrics-core (178 tests) pass on JDK 25. google-java-format 1.37.0 and checkstyle are clean on the changed files. I did not run mise run lint or the exporter modules.

@zeitlinger this changes the key normalization from #1828.

normalizePropertyKey() lowercases the whole key, so settings for a
metric with uppercase letters, such as
io.prometheus.metrics.myLatency.histogram_classic_upper_bounds, are
stored under my_latency and never found for myLatency. Normalize only
the property name in io.prometheus.metrics.<metric>.<property> keys,
so metric names keep their case as they did before 1.5.0.

Signed-off-by: Tanishq Choudhary <tanishqchoudhary007@gmail.com>

@zeitlinger zeitlinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks!

@zeitlinger
zeitlinger enabled auto-merge (squash) October 23, 2026 08:20
@zeitlinger
zeitlinger merged commit e319d3b into prometheus:main Oct 23, 2026
18 checks passed
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.

2 participants