Class Histogram.Child

    • Field Detail

      • exemplars

        private final java.util.ArrayList<java.util.concurrent.atomic.AtomicReference<Exemplar>> exemplars
      • exemplarsEnabled

        private final java.lang.Boolean exemplarsEnabled
      • upperBounds

        private final double[] upperBounds
      • cumulativeCounts

        private final DoubleAdder[] cumulativeCounts
      • created

        private final long created
    • Constructor Detail

      • Child

        private Child​(double[] buckets,
                      java.lang.Boolean exemplarsEnabled,
                      HistogramExemplarSampler exemplarSampler)
    • Method Detail

      • time

        public double time​(java.lang.Runnable timeable)
        Executes runnable code (e.g. a Java 8 Lambda) and observes a duration of how long it took to run.
        Parameters:
        timeable - Code that is being timed
        Returns:
        Measured duration in seconds for timeable to complete.
      • timeWithExemplar

        public double timeWithExemplar​(java.lang.Runnable timeable,
                                       java.lang.String... exemplarLabels)
        Like time(Runnable), but additionally create an exemplar.

        See observeWithExemplar(double, String...) for documentation on the exemplarLabels parameter.

      • timeWithExemplar

        public double timeWithExemplar​(java.lang.Runnable timeable,
                                       java.util.Map<java.lang.String,​java.lang.String> exemplarLabels)
        Like time(Runnable), but additionally create an exemplar.

        See observeWithExemplar(double, Map) for documentation on the exemplarLabels parameter.

      • time

        public <E> E time​(java.util.concurrent.Callable<E> timeable)
        Executes callable code (e.g. a Java 8 Lambda) and observes a duration of how long it took to run.
        Parameters:
        timeable - Code that is being timed
        Returns:
        Result returned by callable.
      • timeWithExemplar

        public <E> E timeWithExemplar​(java.util.concurrent.Callable<E> timeable,
                                      java.lang.String... exemplarLabels)
        Like time(Callable), but additionally create an exemplar.

        See observeWithExemplar(double, String...) for documentation on the exemplarLabels parameter.

      • timeWithExemplar

        public <E> E timeWithExemplar​(java.util.concurrent.Callable<E> timeable,
                                      java.util.Map<java.lang.String,​java.lang.String> exemplarLabels)
        Like time(Callable), but additionally create an exemplar.

        See observeWithExemplar(double, Map) for documentation on the exemplarLabels parameter.

      • observeWithExemplar

        public void observeWithExemplar​(double amt,
                                        java.lang.String... exemplarLabels)
        Like observe(double), but additionally creates an exemplar.

        This exemplar takes precedence over any exemplar returned by the HistogramExemplarSampler configured in ExemplarConfig.

        The exemplar will have amt as the value, System.currentTimeMillis() as the timestamp, and the specified labels.

        Parameters:
        amt - same as in observe(double) (double)}
        exemplarLabels - list of name/value pairs, as documented in Exemplar(double, String...). A commonly used name is "trace_id". Calling observeWithExemplar(amt) means that an exemplar without labels is created. Calling observeWithExemplar(amt, (String[]) null) is equivalent to calling observe(amt).
      • observeWithExemplar

        public void observeWithExemplar​(double amt,
                                        java.util.Map<java.lang.String,​java.lang.String> exemplarLabels)
        Like observeWithExemplar(double, String...), but the exemplar labels are passed as a Map.
      • updateExemplar

        private void updateExemplar​(double amt,
                                    int i,
                                    Exemplar userProvidedExemplar)
      • sampleNextExemplar

        private Exemplar sampleNextExemplar​(double amt,
                                            double bucketFrom,
                                            double bucketTo,
                                            Exemplar prev)