Class Counter.Builder

java.lang.Object
io.micrometer.core.instrument.Counter.Builder
Enclosing interface:
Counter

public static class Counter.Builder
extends java.lang.Object
Fluent builder for counters.
  • Method Details

    • tags

      public Counter.Builder tags​(java.lang.String... tags)
      Parameters:
      tags - Must be an even number of arguments representing key/value pairs of tags.
      Returns:
      The counter builder with added tags.
    • tags

      public Counter.Builder tags​(java.lang.Iterable<Tag> tags)
      Parameters:
      tags - Tags to add to the eventual counter.
      Returns:
      The counter builder with added tags.
    • tag

      public Counter.Builder tag​(java.lang.String key, java.lang.String value)
      Parameters:
      key - The tag key.
      value - The tag value.
      Returns:
      The counter builder with a single added tag.
    • description

      public Counter.Builder description​(@Nullable java.lang.String description)
      Parameters:
      description - Description text of the eventual counter.
      Returns:
      The counter builder with added description.
    • baseUnit

      public Counter.Builder baseUnit​(@Nullable java.lang.String unit)
      Parameters:
      unit - Base unit of the eventual counter.
      Returns:
      The counter builder with added base unit.
    • register

      public Counter register​(MeterRegistry registry)
      Add the counter to a single registry, or return an existing counter in that registry. The returned counter will be unique for each registry, but each registry is guaranteed to only create one counter for the same combination of name and tags.
      Parameters:
      registry - A registry to add the counter to, if it doesn't already exist.
      Returns:
      A new or existing counter.