Class Counter.Child

    • Field Detail

      • created

        private final long created
      • exemplarsEnabled

        private final java.lang.Boolean exemplarsEnabled
      • exemplar

        private final java.util.concurrent.atomic.AtomicReference<Exemplar> exemplar
    • Constructor Detail

      • Child

        public Child()
    • Method Detail

      • inc

        public void inc()
        Increment the counter by 1.
      • inc

        public void inc​(double amt)
        Increment the counter by the given amount.
        Throws:
        java.lang.IllegalArgumentException - If amt is negative.
      • incWithExemplar

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

        This exemplar takes precedence over any exemplar returned by the CounterExemplarSampler 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 inc(double)
        exemplarLabels - list of name/value pairs, as documented in Exemplar(double, String...). A commonly used name is "trace_id". Calling incWithExemplar(amt) means that an exemplar without labels will be created. Calling incWithExemplar(amt, (String[]) null) is equivalent to calling inc(amt).
      • incWithExemplar

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

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

        private Exemplar sampleNextExemplar​(double amt,
                                            Exemplar prev)
      • get

        public double get()
        Get the value of the counter.
      • getExemplar

        private Exemplar getExemplar()
      • created

        public long created()
        Get the created time of the counter in milliseconds.