diff --git a/prometheus-metrics-instrumentation-dropwizard/src/main/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExports.java b/prometheus-metrics-instrumentation-dropwizard/src/main/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExports.java index dd656fcd7..66957de42 100644 --- a/prometheus-metrics-instrumentation-dropwizard/src/main/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExports.java +++ b/prometheus-metrics-instrumentation-dropwizard/src/main/java/io/prometheus/metrics/instrumentation/dropwizard/DropwizardExports.java @@ -169,8 +169,10 @@ MetricSnapshot fromSnapshotAndCount( .quantile(0.999, snapshot.get999thPercentile() * factor) .build(); + String name = + labelMapper.isPresent() ? labelMapper.get().getName(dropwizardName) : dropwizardName; MetricMetadata metadata = - new MetricMetadata(PrometheusNaming.sanitizeMetricName(dropwizardName), helpMessage); + new MetricMetadata(PrometheusNaming.sanitizeMetricName(name), helpMessage); SummarySnapshot.SummaryDataPointSnapshot.Builder dataPointBuilder = SummarySnapshot.SummaryDataPointSnapshot.builder().quantiles(quantiles).count(count); labelMapper.ifPresent( diff --git a/prometheus-metrics-instrumentation-dropwizard5/src/main/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExports.java b/prometheus-metrics-instrumentation-dropwizard5/src/main/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExports.java index e6631188d..a8ee9916f 100644 --- a/prometheus-metrics-instrumentation-dropwizard5/src/main/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExports.java +++ b/prometheus-metrics-instrumentation-dropwizard5/src/main/java/io/prometheus/metrics/instrumentation/dropwizard5/DropwizardExports.java @@ -169,8 +169,10 @@ MetricSnapshot fromSnapshotAndCount( .quantile(0.999, snapshot.get999thPercentile() * factor) .build(); + String name = + labelMapper.isPresent() ? labelMapper.get().getName(dropwizardName) : dropwizardName; MetricMetadata metadata = - new MetricMetadata(PrometheusNaming.sanitizeMetricName(dropwizardName), helpMessage); + new MetricMetadata(PrometheusNaming.sanitizeMetricName(name), helpMessage); SummarySnapshot.SummaryDataPointSnapshot.Builder dataPointBuilder = SummarySnapshot.SummaryDataPointSnapshot.builder().quantiles(quantiles).count(count); labelMapper.ifPresent(