Skip to content

Commit a8c026a

Browse files
committed
Expose Prometheus#histogramFlavor property
Closes gh-20853
1 parent f64f5a0 commit a8c026a

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusProperties.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
2020
import java.util.HashMap;
2121
import java.util.Map;
2222

23+
import io.micrometer.prometheus.HistogramFlavor;
24+
2325
import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusPushGatewayManager.ShutdownOperation;
2426
import org.springframework.boot.context.properties.ConfigurationProperties;
2527

@@ -46,6 +48,11 @@ public class PrometheusProperties {
4648
*/
4749
private final Pushgateway pushgateway = new Pushgateway();
4850

51+
/**
52+
* Histogram type for backing DistributionSummary and Timer.
53+
*/
54+
private HistogramFlavor histogramFlavor = HistogramFlavor.Prometheus;
55+
4956
/**
5057
* Step size (i.e. reporting frequency) to use.
5158
*/
@@ -59,6 +66,14 @@ public void setDescriptions(boolean descriptions) {
5966
this.descriptions = descriptions;
6067
}
6168

69+
public HistogramFlavor getHistogramFlavor() {
70+
return this.histogramFlavor;
71+
}
72+
73+
public void setHistogramFlavor(HistogramFlavor histogramFlavor) {
74+
this.histogramFlavor = histogramFlavor;
75+
}
76+
6277
public Duration getStep() {
6378
return this.step;
6479
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesConfigAdapter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import java.time.Duration;
2020

21+
import io.micrometer.prometheus.HistogramFlavor;
2122
import io.micrometer.prometheus.PrometheusConfig;
2223

2324
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter;
@@ -45,6 +46,11 @@ public boolean descriptions() {
4546
return get(PrometheusProperties::isDescriptions, PrometheusConfig.super::descriptions);
4647
}
4748

49+
@Override
50+
public HistogramFlavor histogramFlavor() {
51+
return get(PrometheusProperties::getHistogramFlavor, PrometheusConfig.super::histogramFlavor);
52+
}
53+
4854
@Override
4955
public Duration step() {
5056
return get(PrometheusProperties::getStep, PrometheusConfig.super::step);

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@
328328
"description": "Whether exporting of metrics to Prometheus is enabled.",
329329
"defaultValue": true
330330
},
331+
{
332+
"name": "management.metrics.export.prometheus.histogram-flavor",
333+
"defaultValue": "prometheus"
334+
},
331335
{
332336
"name": "management.metrics.export.signalfx.num-threads",
333337
"type": "java.lang.Integer",

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ void defaultValuesAreConsistent() {
3333
PrometheusProperties properties = new PrometheusProperties();
3434
PrometheusConfig config = PrometheusConfig.DEFAULT;
3535
assertThat(properties.isDescriptions()).isEqualTo(config.descriptions());
36+
assertThat(properties.getHistogramFlavor()).isEqualTo(config.histogramFlavor());
3637
assertThat(properties.getStep()).isEqualTo(config.step());
3738
}
3839

0 commit comments

Comments
 (0)