Commit a8c026a5 authored by Stephane Nicoll's avatar Stephane Nicoll

Expose Prometheus#histogramFlavor property

Closes gh-20853
parent f64f5a0f
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,6 +20,8 @@ import java.time.Duration; ...@@ -20,6 +20,8 @@ import java.time.Duration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import io.micrometer.prometheus.HistogramFlavor;
import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusPushGatewayManager.ShutdownOperation; import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusPushGatewayManager.ShutdownOperation;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
...@@ -46,6 +48,11 @@ public class PrometheusProperties { ...@@ -46,6 +48,11 @@ public class PrometheusProperties {
*/ */
private final Pushgateway pushgateway = new Pushgateway(); private final Pushgateway pushgateway = new Pushgateway();
/**
* Histogram type for backing DistributionSummary and Timer.
*/
private HistogramFlavor histogramFlavor = HistogramFlavor.Prometheus;
/** /**
* Step size (i.e. reporting frequency) to use. * Step size (i.e. reporting frequency) to use.
*/ */
...@@ -59,6 +66,14 @@ public class PrometheusProperties { ...@@ -59,6 +66,14 @@ public class PrometheusProperties {
this.descriptions = descriptions; this.descriptions = descriptions;
} }
public HistogramFlavor getHistogramFlavor() {
return this.histogramFlavor;
}
public void setHistogramFlavor(HistogramFlavor histogramFlavor) {
this.histogramFlavor = histogramFlavor;
}
public Duration getStep() { public Duration getStep() {
return this.step; return this.step;
} }
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,6 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus ...@@ -18,6 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus
import java.time.Duration; import java.time.Duration;
import io.micrometer.prometheus.HistogramFlavor;
import io.micrometer.prometheus.PrometheusConfig; import io.micrometer.prometheus.PrometheusConfig;
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter; import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter;
...@@ -45,6 +46,11 @@ class PrometheusPropertiesConfigAdapter extends PropertiesConfigAdapter<Promethe ...@@ -45,6 +46,11 @@ class PrometheusPropertiesConfigAdapter extends PropertiesConfigAdapter<Promethe
return get(PrometheusProperties::isDescriptions, PrometheusConfig.super::descriptions); return get(PrometheusProperties::isDescriptions, PrometheusConfig.super::descriptions);
} }
@Override
public HistogramFlavor histogramFlavor() {
return get(PrometheusProperties::getHistogramFlavor, PrometheusConfig.super::histogramFlavor);
}
@Override @Override
public Duration step() { public Duration step() {
return get(PrometheusProperties::getStep, PrometheusConfig.super::step); return get(PrometheusProperties::getStep, PrometheusConfig.super::step);
......
...@@ -328,6 +328,10 @@ ...@@ -328,6 +328,10 @@
"description": "Whether exporting of metrics to Prometheus is enabled.", "description": "Whether exporting of metrics to Prometheus is enabled.",
"defaultValue": true "defaultValue": true
}, },
{
"name": "management.metrics.export.prometheus.histogram-flavor",
"defaultValue": "prometheus"
},
{ {
"name": "management.metrics.export.signalfx.num-threads", "name": "management.metrics.export.signalfx.num-threads",
"type": "java.lang.Integer", "type": "java.lang.Integer",
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -33,6 +33,7 @@ class PrometheusPropertiesTests { ...@@ -33,6 +33,7 @@ class PrometheusPropertiesTests {
PrometheusProperties properties = new PrometheusProperties(); PrometheusProperties properties = new PrometheusProperties();
PrometheusConfig config = PrometheusConfig.DEFAULT; PrometheusConfig config = PrometheusConfig.DEFAULT;
assertThat(properties.isDescriptions()).isEqualTo(config.descriptions()); assertThat(properties.isDescriptions()).isEqualTo(config.descriptions());
assertThat(properties.getHistogramFlavor()).isEqualTo(config.histogramFlavor());
assertThat(properties.getStep()).isEqualTo(config.step()); assertThat(properties.getStep()).isEqualTo(config.step());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment