Class LongUpDownCounter
java.lang.Object
org.bluezoo.gumdrop.telemetry.metrics.LongUpDownCounter
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for LongUpDownCounter. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(long value) Adds a value to the counter (can be positive or negative).voidadd(long value, Attributes attributes) Adds a value to the counter with attributes.collect(AggregationTemporality temporality) Collects the current metric data for export.Returns the instrument description.getName()Returns the instrument name.getUnit()Returns the unit of measurement.
-
Method Details
-
getName
Description copied from interface:InstrumentReturns the instrument name.- Specified by:
getNamein interfaceInstrument
-
getDescription
Description copied from interface:InstrumentReturns the instrument description.- Specified by:
getDescriptionin interfaceInstrument
-
getUnit
Description copied from interface:InstrumentReturns the unit of measurement.- Specified by:
getUnitin interfaceInstrument
-
add
public void add(long value) Adds a value to the counter (can be positive or negative).- Parameters:
value- the value to add
-
add
Adds a value to the counter with attributes.- Parameters:
value- the value to addattributes- the attributes for this measurement
-
collect
Description copied from interface:InstrumentCollects the current metric data for export. Resets delta values if using delta temporality.- Specified by:
collectin interfaceInstrument- Parameters:
temporality- the aggregation temporality to use- Returns:
- the metric data, or null if no data to export
-