Expose Prometheus#histogramFlavor property
Closes gh-20853
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,8 @@ import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.micrometer.prometheus.HistogramFlavor;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusPushGatewayManager.ShutdownOperation;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@@ -46,6 +48,11 @@ public class PrometheusProperties {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@@ -59,6 +66,14 @@ public class PrometheusProperties {
|
||||
this.descriptions = descriptions;
|
||||
}
|
||||
|
||||
public HistogramFlavor getHistogramFlavor() {
|
||||
return this.histogramFlavor;
|
||||
}
|
||||
|
||||
public void setHistogramFlavor(HistogramFlavor histogramFlavor) {
|
||||
this.histogramFlavor = histogramFlavor;
|
||||
}
|
||||
|
||||
public Duration getStep() {
|
||||
return this.step;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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");
|
||||
* 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
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import io.micrometer.prometheus.HistogramFlavor;
|
||||
import io.micrometer.prometheus.PrometheusConfig;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.PropertiesConfigAdapter;
|
||||
@@ -45,6 +46,11 @@ class PrometheusPropertiesConfigAdapter extends PropertiesConfigAdapter<Promethe
|
||||
return get(PrometheusProperties::isDescriptions, PrometheusConfig.super::descriptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HistogramFlavor histogramFlavor() {
|
||||
return get(PrometheusProperties::getHistogramFlavor, PrometheusConfig.super::histogramFlavor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration step() {
|
||||
return get(PrometheusProperties::getStep, PrometheusConfig.super::step);
|
||||
|
||||
@@ -328,6 +328,10 @@
|
||||
"description": "Whether exporting of metrics to Prometheus is enabled.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.metrics.export.prometheus.histogram-flavor",
|
||||
"defaultValue": "prometheus"
|
||||
},
|
||||
{
|
||||
"name": "management.metrics.export.signalfx.num-threads",
|
||||
"type": "java.lang.Integer",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,6 +33,7 @@ class PrometheusPropertiesTests {
|
||||
PrometheusProperties properties = new PrometheusProperties();
|
||||
PrometheusConfig config = PrometheusConfig.DEFAULT;
|
||||
assertThat(properties.isDescriptions()).isEqualTo(config.descriptions());
|
||||
assertThat(properties.getHistogramFlavor()).isEqualTo(config.histogramFlavor());
|
||||
assertThat(properties.getStep()).isEqualTo(config.step());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user