All Superinterfaces:
BasicMetric<Gauge>
All Known Implementing Classes:
NoopGauge, PrometheusGauge

public interface Gauge extends BasicMetric<Gauge>
Gauge metric, to report instantaneous values.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Represents an event being timed.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    decrease(double amount)
    Decrement gauge by given amount.
    default void
    Decrement gauge by 1.
    void
    increase(double amount)
    Increment gauge by given amount.
    default void
    Increment gauge by 1.
    double
    Executes runnable code and observes a duration of how long it took to run.
    <T> T
    Executes runnable code and observes a duration of how long it took to run.
    void
    set(double value)
    Set gauge to given amount.
    Start a timer to track a duration.

    Methods inherited from interface eu.rarogsoftware.rarog.platform.api.metrics.BasicMetric

    labels, labels
  • Method Details

    • increase

      void increase(double amount)
      Increment gauge by given amount.
      Parameters:
      amount - amount to add gauge value
    • increment

      default void increment()
      Increment gauge by 1.
    • decrease

      void decrease(double amount)
      Decrement gauge by given amount.
      Parameters:
      amount - amount to add gauge value
    • decrement

      default void decrement()
      Decrement gauge by 1.
    • set

      void set(double value)
      Set gauge to given amount.
      Parameters:
      value - amount to add gauge value
    • startTimer

      Gauge.Timer startTimer()
      Start a timer to track a duration.

      Call Gauge.Timer.stop() at the end of what you want to measure duration of.

      Gauge.Timer is Closeable to you can use it in try with resources to auto call Gauge.Timer.stop()

      Returns:
      timer object
    • measureExecutionTime

      double measureExecutionTime(Runnable timeable)
      Executes runnable code 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.
    • measureExecutionTime

      <T> T measureExecutionTime(Callable<T> timeable) throws Exception
      Executes runnable code and observes a duration of how long it took to run.
      Parameters:
      timeable - Code that is being timed
      Returns:
      result of timeable function
      Throws:
      Exception - exception thrown by timeable function