Class Configuration


  • public class Configuration
    extends java.lang.Object
    Holds 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 Detail

      • cheapMetricsOnly

        public static Configuration cheapMetricsOnly()
        Returns a Configuration for recording all cheap metrics about the rpcs.
      • allMetrics

        public static Configuration allMetrics()
        Returns a Configuration for 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 copy Configuration with the difference that Prometheus metrics are recorded using the supplied CollectorRegistry.
      • withLatencyBuckets

        public Configuration withLatencyBuckets​(double[] buckets)
        Returns a copy Configuration with 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 copy Configuration that 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 the CollectorRegistry used 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.