Class Counter.Child

java.lang.Object
io.prometheus.client.Counter.Child
Enclosing class:
Counter

public static class Counter.Child extends Object
The value of a single Counter.

Warning: References to a Child become invalid after using SimpleCollector.remove(java.lang.String...) or SimpleCollector.clear(),

  • Field Details

  • Constructor Details

  • Method Details

    • inc

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

      public void incWithExemplar(String... exemplarLabels)
    • incWithExemplar

      public void incWithExemplar(Map<String,String> exemplarLabels)
    • inc

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

      public void incWithExemplar(double amt, 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, Map<String,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.