Class FunctionCounter.Builder<T>

  • Type Parameters:
    T - The type of the state object from which the counter value is extracted.
    Enclosing interface:
    FunctionCounter

    public static class FunctionCounter.Builder<T>
    extends java.lang.Object
    Fluent builder for function counters.
    • Method Detail

      • tags

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

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

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

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

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

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