Package io.micrometer.core.instrument
Class Counter.Builder
java.lang.Object
io.micrometer.core.instrument.Counter.Builder
- Enclosing interface:
Counter
Fluent builder for counters.
-
Method Summary
Modifier and TypeMethodDescriptiondescription
(String description) register
(MeterRegistry registry) Add the counter to a single registry, or return an existing counter in that registry.withRegistry
(MeterRegistry registry) Convenience method to create meters from the builder that only differ in tags.
-
Method Details
-
tags
- Parameters:
tags
- Must be an even number of arguments representing key/value pairs of tags.- Returns:
- The counter builder with added tags.
-
tags
- Parameters:
tags
- Tags to add to the eventual counter.- Returns:
- The counter builder with added tags.
-
tag
- Parameters:
key
- The tag key.value
- The tag value.- Returns:
- The counter builder with a single added tag.
-
description
- Parameters:
description
- Description text of the eventual counter.- Returns:
- The counter builder with added description.
-
baseUnit
- Parameters:
unit
- Base unit of the eventual counter.- Returns:
- The counter builder with added base unit.
-
withRegistry
Convenience method to create meters from the builder that only differ in tags. This method can be used for dynamic tagging by creating the builder once and applying the dynamically changing tags using the returnedMeter.MeterProvider
.- Parameters:
registry
- A registry to add the meter to, if it doesn't already exist.- Returns:
- A
Meter.MeterProvider
that returns a meter based on the provided tags. - Since:
- 1.12.0
-
register
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.
-