Skip to content

Commit 1404b34

Browse files
[DropwizardExport] Apply label mapper to metric name for snapshots
1 parent f7681a4 commit 1404b34

File tree

2 files changed

+4
-2
lines changed
  • prometheus-metrics-instrumentation-dropwizard5/src/main/java/io/prometheus/metrics/instrumentation/dropwizard5
  • prometheus-metrics-instrumentation-dropwizard/src/main/java/io/prometheus/metrics/instrumentation/dropwizard

2 files changed

+4
-2
lines changed

prometheus-metrics-instrumentation-dropwizard/src/main/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExports.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ MetricSnapshot fromSnapshotAndCount(
146146
.quantile(0.999, snapshot.get999thPercentile() * factor)
147147
.build();
148148

149+
String name = labelMapper.isPresent() ? labelMapper.get().getName(dropwizardName) : dropwizardName;
149150
MetricMetadata metadata =
150-
new MetricMetadata(PrometheusNaming.sanitizeMetricName(dropwizardName), helpMessage);
151+
new MetricMetadata(PrometheusNaming.sanitizeMetricName(name), helpMessage);
151152
SummarySnapshot.SummaryDataPointSnapshot.Builder dataPointBuilder =
152153
SummarySnapshot.SummaryDataPointSnapshot.builder().quantiles(quantiles).count(count);
153154
labelMapper.ifPresent(

prometheus-metrics-instrumentation-dropwizard5/src/main/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExports.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ MetricSnapshot fromSnapshotAndCount(
149149
.quantile(0.999, snapshot.get999thPercentile() * factor)
150150
.build();
151151

152+
String name = labelMapper.isPresent() ? labelMapper.get().getName(dropwizardName) : dropwizardName;
152153
MetricMetadata metadata =
153-
new MetricMetadata(PrometheusNaming.sanitizeMetricName(dropwizardName), helpMessage);
154+
new MetricMetadata(PrometheusNaming.sanitizeMetricName(name), helpMessage);
154155
SummarySnapshot.SummaryDataPointSnapshot.Builder dataPointBuilder =
155156
SummarySnapshot.SummaryDataPointSnapshot.builder().quantiles(quantiles).count(count);
156157
labelMapper.ifPresent(

0 commit comments

Comments
 (0)