Skip to content

Commit 7447816

Browse files
Dropwizard apply label mapper to snapshot metrics (#1266)
Also allowed to override getHelpMessage --------- Signed-off-by: Kacper Filutowski <[email protected]> Signed-off-by: Gregor Zeitlinger <[email protected]> Co-authored-by: Gregor Zeitlinger <[email protected]>
1 parent 2678bcc commit 7447816

File tree

2 files changed

+6
-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

+6
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ MetricSnapshot fromSnapshotAndCount(
169169
.quantile(0.999, snapshot.get999thPercentile() * factor)
170170
.build();
171171

172+
String name =
173+
labelMapper.isPresent() ? labelMapper.get().getName(dropwizardName) : dropwizardName;
172174
MetricMetadata metadata =
173-
new MetricMetadata(PrometheusNaming.sanitizeMetricName(dropwizardName), helpMessage);
175+
new MetricMetadata(PrometheusNaming.sanitizeMetricName(name), helpMessage);
174176
SummarySnapshot.SummaryDataPointSnapshot.Builder dataPointBuilder =
175177
SummarySnapshot.SummaryDataPointSnapshot.builder().quantiles(quantiles).count(count);
176178
labelMapper.ifPresent(

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ MetricSnapshot fromSnapshotAndCount(
169169
.quantile(0.999, snapshot.get999thPercentile() * factor)
170170
.build();
171171

172+
String name =
173+
labelMapper.isPresent() ? labelMapper.get().getName(dropwizardName) : dropwizardName;
172174
MetricMetadata metadata =
173-
new MetricMetadata(PrometheusNaming.sanitizeMetricName(dropwizardName), helpMessage);
175+
new MetricMetadata(PrometheusNaming.sanitizeMetricName(name), helpMessage);
174176
SummarySnapshot.SummaryDataPointSnapshot.Builder dataPointBuilder =
175177
SummarySnapshot.SummaryDataPointSnapshot.builder().quantiles(quantiles).count(count);
176178
labelMapper.ifPresent(

0 commit comments

Comments
 (0)