Class LongUpDownCounter

java.lang.Object
org.bluezoo.gumdrop.telemetry.metrics.LongUpDownCounter
All Implemented Interfaces:
Instrument

public final class LongUpDownCounter extends Object implements Instrument
A counter that can increase or decrease. Useful for tracking things like active connections, queue size, etc.

Example usage:

 LongUpDownCounter activeConnections = meter.upDownCounterBuilder("connections.active")
     .setDescription("Number of active connections")
     .build();
 
 activeConnections.add(1);   // Connection opened
 activeConnections.add(-1);  // Connection closed
 
Author:
Chris Burdess
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Instrument
      Returns the instrument name.
      Specified by:
      getName in interface Instrument
    • getDescription

      public String getDescription()
      Description copied from interface: Instrument
      Returns the instrument description.
      Specified by:
      getDescription in interface Instrument
    • getUnit

      public String getUnit()
      Description copied from interface: Instrument
      Returns the unit of measurement.
      Specified by:
      getUnit in interface Instrument
    • add

      public void add(long value)
      Adds a value to the counter (can be positive or negative).
      Parameters:
      value - the value to add
    • add

      public void add(long value, Attributes attributes)
      Adds a value to the counter with attributes.
      Parameters:
      value - the value to add
      attributes - the attributes for this measurement
    • collect

      public MetricData collect(AggregationTemporality temporality)
      Description copied from interface: Instrument
      Collects the current metric data for export. Resets delta values if using delta temporality.
      Specified by:
      collect in interface Instrument
      Parameters:
      temporality - the aggregation temporality to use
      Returns:
      the metric data, or null if no data to export