Interface GaugeDataPoint

All Superinterfaces:
DataPoint, TimerApi
All Known Implementing Classes:
Gauge

public interface GaugeDataPoint extends DataPoint, TimerApi
Represents a single gauge data point, i.e. a single line for a gauge metric in Prometheus text format.

See JavaDoc of CounterDataPoint on how using data points directly can improve performance.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    dec()
    Subtract one.
    default void
    dec(double amount)
    Subtract amount.
    default void
    decWithExemplar(double amount, Labels labels)
    Subtract amount, and create a custom exemplar with the given labels.
    default void
    Subtract one, and create a custom exemplar with the given labels.
    double
    get()
    Get the current value.
    default void
    inc()
    Add one.
    void
    inc(double amount)
    Add amount.
    void
    incWithExemplar(double amount, Labels labels)
    Add amount, and create a custom exemplar with the given labels.
    default void
    Add one, and create a custom exemplar with the given labels.
    void
    set(double value)
    Set the gauge to value.
    void
    setWithExemplar(double value, Labels labels)
    Set the gauge to value, and create a custom exemplar with the given labels.
    default Timer
    Start a Timer.

    Methods inherited from interface TimerApi

    time, time, timeChecked
  • Method Details

    • inc

      default void inc()
      Add one.
    • inc

      void inc(double amount)
      Add amount.
    • incWithExemplar

      default void incWithExemplar(Labels labels)
      Add one, and create a custom exemplar with the given labels.
    • incWithExemplar

      void incWithExemplar(double amount, Labels labels)
      Add amount, and create a custom exemplar with the given labels.
    • dec

      default void dec()
      Subtract one.
    • dec

      default void dec(double amount)
      Subtract amount.
    • decWithExemplar

      default void decWithExemplar(Labels labels)
      Subtract one, and create a custom exemplar with the given labels.
    • decWithExemplar

      default void decWithExemplar(double amount, Labels labels)
      Subtract amount, and create a custom exemplar with the given labels.
    • set

      void set(double value)
      Set the gauge to value.
    • get

      double get()
      Get the current value.
    • setWithExemplar

      void setWithExemplar(double value, Labels labels)
      Set the gauge to value, and create a custom exemplar with the given labels.
    • startTimer

      default Timer startTimer()
      Description copied from interface: TimerApi
      Start a Timer. Example:
      
       Histogram histogram = Histogram.builder()
               .name("http_request_duration_seconds")
               .help("HTTP request service time in seconds")
               .unit(SECONDS)
               .labelNames("method", "path")
               .register();
      
       try (Timer timer = histogram.labelValues("GET", "/").startTimer()) {
           // duration of this code block will be observed.
       }
       
      Durations are recorded in seconds. The Prometheus instrumentation guidelines say: "Metrics must use base units (e.g. seconds, bytes) and leave converting them to something more readable to graphing tools".
      Specified by:
      startTimer in interface TimerApi