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 <kacper.filutowski@tomtom.com> Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com> Co-authored-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent 2678bcc commit 7447816

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

  • prometheus-metrics-instrumentation-dropwizard5/src/main/java/io/prometheus/metrics/instrumentation/dropwizard5
  • prometheus-metrics-instrumentation-dropwizard/src/main/java/io/prometheus/metrics/instrumentation/dropwizard

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)