Package me.dinowernli.grpc.prometheus
Class Configuration
- java.lang.Object
-
- me.dinowernli.grpc.prometheus.Configuration
-
public class Configuration extends java.lang.ObjectHolds information about which metrics should be kept track of during rpc calls. Can be used to turn on more elaborate and expensive metrics, such as latency histograms.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConfigurationallMetrics()Returns aConfigurationfor recording all metrics about the rpcs.static ConfigurationcheapMetricsOnly()Returns aConfigurationfor recording all cheap metrics about the rpcs.io.prometheus.client.CollectorRegistrygetCollectorRegistry()Returns theCollectorRegistryused to record stats.java.util.List<java.lang.String>getLabelHeaders()Returns the configured list of headers to be used as labels.double[]getLatencyBuckets()Returns the histogram buckets to use for latency metrics.java.util.List<java.lang.String>getSanitizedLabelHeaders()Returns the sanitized version of the label headers, after turning all hyphens to underscores.booleanisIncludeLatencyHistograms()Returns whether or not latency histograms for calls should be included.ConfigurationwithCollectorRegistry(io.prometheus.client.CollectorRegistry collectorRegistry)Returns a copyConfigurationwith the difference that Prometheus metrics are recorded using the suppliedCollectorRegistry.ConfigurationwithLabelHeaders(java.util.List<java.lang.String> headers)Returns a copyConfigurationthat recognizes the given list of header names and uses their value from each request as prometheus labels.ConfigurationwithLatencyBuckets(double[] buckets)Returns a copyConfigurationwith the difference that the latency histogram values are recorded with the specified set of buckets.
-
-
-
Method Detail
-
cheapMetricsOnly
public static Configuration cheapMetricsOnly()
Returns aConfigurationfor recording all cheap metrics about the rpcs.
-
allMetrics
public static Configuration allMetrics()
Returns aConfigurationfor recording all metrics about the rpcs. This includes metrics which might produce a lot of data, such as latency histograms.
-
withCollectorRegistry
public Configuration withCollectorRegistry(io.prometheus.client.CollectorRegistry collectorRegistry)
Returns a copyConfigurationwith the difference that Prometheus metrics are recorded using the suppliedCollectorRegistry.
-
withLatencyBuckets
public Configuration withLatencyBuckets(double[] buckets)
Returns a copyConfigurationwith the difference that the latency histogram values are recorded with the specified set of buckets.
-
withLabelHeaders
public Configuration withLabelHeaders(java.util.List<java.lang.String> headers)
Returns a copyConfigurationthat recognizes the given list of header names and uses their value from each request as prometheus labels. Since hyphens is a common character in header names, and since Prometheus does not allow hyphens in label names, All hyphens in the list of header names will be converted to underscores before being added as metric label names. If one of the headers added here is absent in one of the requests, its metric value for that request will be an empty string. Example:withLabelHeaders(Arrays.asList("User-Agent"))will make all metrics carry a label "User_Agent", with label value filled in from the value of the "User-Agent" header of each request.
-
isIncludeLatencyHistograms
public boolean isIncludeLatencyHistograms()
Returns whether or not latency histograms for calls should be included.
-
getCollectorRegistry
public io.prometheus.client.CollectorRegistry getCollectorRegistry()
Returns theCollectorRegistryused to record stats.
-
getLatencyBuckets
public double[] getLatencyBuckets()
Returns the histogram buckets to use for latency metrics.
-
getLabelHeaders
public java.util.List<java.lang.String> getLabelHeaders()
Returns the configured list of headers to be used as labels.
-
getSanitizedLabelHeaders
public java.util.List<java.lang.String> getSanitizedLabelHeaders()
Returns the sanitized version of the label headers, after turning all hyphens to underscores.
-
-