Class LongCounter

java.lang.Object
com.gigaspaces.metrics.Metric
com.gigaspaces.metrics.LongCounter

@Deprecated public class LongCounter extends Metric
Deprecated.
Use AtomicLong with Micrometer Gauge, or Counter for monotonic counters
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
    Constructor
    Description
    Deprecated.
     
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dec()
    Deprecated.
    Decrement the counter by one.
    void
    dec(long n)
    Deprecated.
    Decrement the counter by n.
    long
    Deprecated.
    Returns the counter's current value.
    void
    inc()
    Deprecated.
    Increment the counter by one.
    void
    inc(long n)
    Deprecated.
    Increment the counter by n.
    void
    Deprecated.
    Resets the counter to zero.
    void
    set(long n)
    Deprecated.
    Override set value of counter by two operations, should manually ensure atomicy

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LongCounter

      public LongCounter()
      Deprecated.
    • LongCounter

      public LongCounter(LongAdder longAdder)
      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 by n.
      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 by n.
      Parameters:
      n - the amount by which the counter will be decreased
    • reset

      public void reset()
      Deprecated.
      Resets the counter to zero.