Package io.micrometer.prometheus
Class PrometheusMeterRegistry
java.lang.Object
io.micrometer.core.instrument.MeterRegistry
io.micrometer.prometheus.PrometheusMeterRegistry
public class PrometheusMeterRegistry
extends io.micrometer.core.instrument.MeterRegistry
MeterRegistry for Prometheus.-
Nested Class Summary
Nested classes/interfaces inherited from class io.micrometer.core.instrument.MeterRegistry
io.micrometer.core.instrument.MeterRegistry.Config, io.micrometer.core.instrument.MeterRegistry.More -
Field Summary
Fields inherited from class io.micrometer.core.instrument.MeterRegistry
clock -
Constructor Summary
Constructors Constructor Description PrometheusMeterRegistry(PrometheusConfig config)PrometheusMeterRegistry(PrometheusConfig config, io.prometheus.client.CollectorRegistry registry, io.micrometer.core.instrument.Clock clock) -
Method Summary
Modifier and Type Method Description protected io.micrometer.core.instrument.distribution.DistributionStatisticConfigdefaultHistogramConfig()protected java.util.concurrent.TimeUnitgetBaseTimeUnit()io.prometheus.client.CollectorRegistrygetPrometheusRegistry()io.micrometer.core.instrument.CounternewCounter(io.micrometer.core.instrument.Meter.Id id)io.micrometer.core.instrument.DistributionSummarynewDistributionSummary(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.distribution.DistributionStatisticConfig distributionStatisticConfig, double scale)protected <T> io.micrometer.core.instrument.FunctionCounternewFunctionCounter(io.micrometer.core.instrument.Meter.Id id, T obj, java.util.function.ToDoubleFunction<T> countFunction)protected <T> io.micrometer.core.instrument.FunctionTimernewFunctionTimer(io.micrometer.core.instrument.Meter.Id id, T obj, java.util.function.ToLongFunction<T> countFunction, java.util.function.ToDoubleFunction<T> totalTimeFunction, java.util.concurrent.TimeUnit totalTimeFunctionUnit)protected <T> io.micrometer.core.instrument.GaugenewGauge(io.micrometer.core.instrument.Meter.Id id, T obj, java.util.function.ToDoubleFunction<T> valueFunction)protected io.micrometer.core.instrument.LongTaskTimernewLongTaskTimer(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.distribution.DistributionStatisticConfig distributionStatisticConfig)protected io.micrometer.core.instrument.MeternewMeter(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.Meter.Type type, java.lang.Iterable<io.micrometer.core.instrument.Measurement> measurements)protected io.micrometer.core.instrument.TimernewTimer(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.distribution.DistributionStatisticConfig distributionStatisticConfig, io.micrometer.core.instrument.distribution.pause.PauseDetector pauseDetector)java.lang.Stringscrape()voidscrape(java.io.Writer writer)Scrape to the specified writer in Prometheus text format.voidscrape(java.io.Writer writer, java.lang.String contentType)Write the metrics scrape body in a specific content type to the given writer.voidscrape(java.io.Writer writer, java.lang.String contentType, java.util.Set<java.lang.String> includedNames)Scrape to the specified writer.java.lang.Stringscrape(java.lang.String contentType)Get the metrics scrape body in a specific content type.java.lang.Stringscrape(java.lang.String contentType, java.util.Set<java.lang.String> includedNames)Return text for scraping.PrometheusMeterRegistrythrowExceptionOnRegistrationFailure()For use withMeterRegistry.Config#onMeterRegistrationFailed(BiConsumer)when you want meters with the same name but different tags to cause an unchecked exception.Methods inherited from class io.micrometer.core.instrument.MeterRegistry
clear, close, config, counter, counter, find, forEachMeter, gauge, gauge, gauge, gauge, gaugeCollectionSize, gaugeMapSize, get, getConventionName, getConventionTags, getMeters, isClosed, meterRegistrationFailed, more, newLongTaskTimer, newTimeGauge, remove, remove, removeByPreFilterId, summary, summary, timer, timerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
PrometheusMeterRegistry
-
PrometheusMeterRegistry
public PrometheusMeterRegistry(PrometheusConfig config, io.prometheus.client.CollectorRegistry registry, io.micrometer.core.instrument.Clock clock)
-
-
Method Details
-
scrape
public java.lang.String scrape()- Returns:
- Content in Prometheus text format for the response body of an endpoint designated for Prometheus to scrape.
-
scrape
public java.lang.String scrape(java.lang.String contentType)Get the metrics scrape body in a specific content type.- Parameters:
contentType- the scrape Content-Type- Returns:
- the scrape body
- Since:
- 1.7.0
- See Also:
TextFormat
-
scrape
public void scrape(java.io.Writer writer) throws java.io.IOExceptionScrape to the specified writer in Prometheus text format.- Parameters:
writer- Target that serves the content to be scraped by Prometheus.- Throws:
java.io.IOException- if writing fails- Since:
- 1.2.0
-
scrape
public void scrape(java.io.Writer writer, java.lang.String contentType) throws java.io.IOExceptionWrite the metrics scrape body in a specific content type to the given writer.- Parameters:
writer- where to write the scrape bodycontentType- the Content-Type of the scrape- Throws:
java.io.IOException- if writing fails- Since:
- 1.7.0
- See Also:
TextFormat
-
scrape
public java.lang.String scrape(java.lang.String contentType, @Nullable java.util.Set<java.lang.String> includedNames)Return text for scraping.- Parameters:
contentType- the Content-Type of the scrape.includedNames- Sample names to be included. All samples will be included ifnull.- Returns:
- Content that should be included in the response body for an endpoint designated for Prometheus to scrape from.
- Since:
- 1.7.0
-
scrape
public void scrape(java.io.Writer writer, java.lang.String contentType, @Nullable java.util.Set<java.lang.String> includedNames) throws java.io.IOExceptionScrape to the specified writer.- Parameters:
writer- Target that serves the content to be scraped by Prometheus.contentType- the Content-Type of the scrape.includedNames- Sample names to be included. All samples will be included ifnull.- Throws:
java.io.IOException- if writing fails- Since:
- 1.7.0
-
newCounter
public io.micrometer.core.instrument.Counter newCounter(io.micrometer.core.instrument.Meter.Id id)- Specified by:
newCounterin classio.micrometer.core.instrument.MeterRegistry
-
newDistributionSummary
public io.micrometer.core.instrument.DistributionSummary newDistributionSummary(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.distribution.DistributionStatisticConfig distributionStatisticConfig, double scale)- Specified by:
newDistributionSummaryin classio.micrometer.core.instrument.MeterRegistry
-
newTimer
protected io.micrometer.core.instrument.Timer newTimer(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.distribution.DistributionStatisticConfig distributionStatisticConfig, io.micrometer.core.instrument.distribution.pause.PauseDetector pauseDetector)- Specified by:
newTimerin classio.micrometer.core.instrument.MeterRegistry
-
newGauge
protected <T> io.micrometer.core.instrument.Gauge newGauge(io.micrometer.core.instrument.Meter.Id id, @Nullable T obj, java.util.function.ToDoubleFunction<T> valueFunction)- Specified by:
newGaugein classio.micrometer.core.instrument.MeterRegistry
-
newLongTaskTimer
protected io.micrometer.core.instrument.LongTaskTimer newLongTaskTimer(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.distribution.DistributionStatisticConfig distributionStatisticConfig)- Overrides:
newLongTaskTimerin classio.micrometer.core.instrument.MeterRegistry
-
newFunctionTimer
protected <T> io.micrometer.core.instrument.FunctionTimer newFunctionTimer(io.micrometer.core.instrument.Meter.Id id, T obj, java.util.function.ToLongFunction<T> countFunction, java.util.function.ToDoubleFunction<T> totalTimeFunction, java.util.concurrent.TimeUnit totalTimeFunctionUnit)- Specified by:
newFunctionTimerin classio.micrometer.core.instrument.MeterRegistry
-
newFunctionCounter
protected <T> io.micrometer.core.instrument.FunctionCounter newFunctionCounter(io.micrometer.core.instrument.Meter.Id id, T obj, java.util.function.ToDoubleFunction<T> countFunction)- Specified by:
newFunctionCounterin classio.micrometer.core.instrument.MeterRegistry
-
newMeter
protected io.micrometer.core.instrument.Meter newMeter(io.micrometer.core.instrument.Meter.Id id, io.micrometer.core.instrument.Meter.Type type, java.lang.Iterable<io.micrometer.core.instrument.Measurement> measurements)- Specified by:
newMeterin classio.micrometer.core.instrument.MeterRegistry
-
getBaseTimeUnit
protected java.util.concurrent.TimeUnit getBaseTimeUnit()- Specified by:
getBaseTimeUnitin classio.micrometer.core.instrument.MeterRegistry
-
getPrometheusRegistry
public io.prometheus.client.CollectorRegistry getPrometheusRegistry()- Returns:
- The underlying Prometheus
CollectorRegistry.
-
defaultHistogramConfig
protected io.micrometer.core.instrument.distribution.DistributionStatisticConfig defaultHistogramConfig()- Specified by:
defaultHistogramConfigin classio.micrometer.core.instrument.MeterRegistry
-
throwExceptionOnRegistrationFailure
For use withMeterRegistry.Config#onMeterRegistrationFailed(BiConsumer)when you want meters with the same name but different tags to cause an unchecked exception.- Returns:
- This registry
- Since:
- 1.6.0
-