Interface Counter

All Superinterfaces:
Meter, Wrapper, Wrapper

public interface Counter extends Meter
Records a monotonically increasing value that is updated by invoking methods on the Counter instance.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builder for a new counter.

    Nested classes/interfaces inherited from interface Meter

    Meter.BaseUnits, Meter.Id, Meter.Scope, Meter.Type
    Modifier and Type
    Interface
    Description
    static class 
    Common unit declarations (inspired by the list from MicroProfile metrics).
    static interface 
    Unique idenfier for a meter.
    static class 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Core metrics ignores scope values, and this type will be removed.
    static enum 
    Type of meter.
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    this method uses service registry to get a MetricsFactory instance, which may be inefficient, use MetricsFactory.counterBuilder(String) instead
    long
    Returns the cumulative count since this counter was registered.
    void
    Updates the counter by one.
    void
    increment(long amount)
    Updates the counter by the specified amount which should be non-negative.

    Methods inherited from interface Meter

    baseUnit, description, id, scope, type
    Modifier and Type
    Method
    Description
    Returns the meter's base unit.
    Returns the meter's description.
    id()
    Returns the meter ID.
    default Optional<String>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Core metrics does not assign scopes, and this method will be removed.
    Returns the meter type.

    Methods inherited from interface Wrapper

    unwrap
    Modifier and Type
    Method
    Description
    <T> T
    unwrap(Class<? extends T> type)
    Unwraps the delegate as the specified type.
  • Method Details

    • builder

      @Deprecated(forRemoval=true, since="27.0.0") static Counter.Builder builder(String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      this method uses service registry to get a MetricsFactory instance, which may be inefficient, use MetricsFactory.counterBuilder(String) instead
      Creates a new builder for a counter.
      Parameters:
      name - counter name
      Returns:
      new builder
    • increment

      void increment()
      Updates the counter by one.
    • increment

      void increment(long amount)
      Updates the counter by the specified amount which should be non-negative.
      Parameters:
      amount - amount to add to the counter.
    • count

      long count()
      Returns the cumulative count since this counter was registered.
      Returns:
      cumulative count since this counter was registered