Package com.gigaspaces.metrics
Class LongCounter
java.lang.Object
com.gigaspaces.metrics.Metric
com.gigaspaces.metrics.LongCounter
Deprecated.
An incrementing and decrementing counter metric for long values.
DEPRECATED: Use AtomicLong directly and register as Micrometer Gauge.
Migration Guide:
// OLD:
LongCounter counter = new LongCounter();
counter.inc();
long value = counter.getCount();
// NEW (for counters that can go up/down):
AtomicLong counter = new AtomicLong(0);
counter.incrementAndGet();
long value = counter.get();
// Register as Micrometer Gauge:
Gauge.builder("metric_name", counter, AtomicLong::get)
.tags(tags)
.register(meterRegistry);
// NEW (for monotonic counters):
Counter counter = Counter.builder("metric_name")
.tags(tags)
.register(meterRegistry);
counter.increment();
double value = counter.count();
- Since:
- 10.1
- Author:
- Niv Ingberg
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddec()Deprecated.Decrement the counter by one.voiddec(long n) Deprecated.Decrement the counter byn.longgetCount()Deprecated.Returns the counter's current value.voidinc()Deprecated.Increment the counter by one.voidinc(long n) Deprecated.Increment the counter byn.voidreset()Deprecated.Resets the counter to zero.voidset(long n) Deprecated.Override set value of counter by two operations, should manually ensure atomicy
-
Constructor Details
-
LongCounter
public LongCounter()Deprecated. -
LongCounter
Deprecated.
-
-
Method Details
-
getCount
public long getCount()Deprecated.Returns the counter's current value.- Returns:
- the counter's current value
-
inc
public void inc()Deprecated.Increment the counter by one. -
inc
public void inc(long n) Deprecated.Increment the counter byn.- Parameters:
n- the amount by which the counter will be increased
-
set
public void set(long n) Deprecated.Override set value of counter by two operations, should manually ensure atomicy- Parameters:
n- the amount by which the counter will be increased
-
dec
public void dec()Deprecated.Decrement the counter by one. -
dec
public void dec(long n) Deprecated.Decrement the counter byn.- Parameters:
n- the amount by which the counter will be decreased
-
reset
public void reset()Deprecated.Resets the counter to zero.
-
AtomicLongwith Micrometer Gauge, orCounterfor monotonic counters