Package io.micrometer.core.instrument
Class Gauge.Builder<T>
- java.lang.Object
-
- io.micrometer.core.instrument.Gauge.Builder<T>
-
- Type Parameters:
T
- The type of the state object from which the gauge value is extracted.
- Enclosing interface:
- Gauge
public static class Gauge.Builder<T> extends java.lang.Object
Fluent builder for gauges.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Gauge.Builder<T>
baseUnit(java.lang.String unit)
Gauge.Builder<T>
description(java.lang.String description)
Gauge
register(MeterRegistry registry)
Add the gauge to a single registry, or return an existing gauge in that registry.Gauge.Builder<T>
strongReference(boolean strong)
Indicates that the gauge should maintain a strong reference on the object upon which its instantaneous value is determined.Gauge.Builder<T>
synthetic(Meter.Id syntheticAssociation)
For internal use.Gauge.Builder<T>
tag(java.lang.String key, java.lang.String value)
Gauge.Builder<T>
tags(java.lang.Iterable<Tag> tags)
Gauge.Builder<T>
tags(java.lang.String... tags)
-
-
-
Method Detail
-
tags
public Gauge.Builder<T> tags(java.lang.String... tags)
- Parameters:
tags
- Must be an even number of arguments representing key/value pairs of tags.- Returns:
- The gauge builder with added tags.
-
tags
public Gauge.Builder<T> tags(java.lang.Iterable<Tag> tags)
- Parameters:
tags
- Tags to add to the eventual gauge.- Returns:
- The gauge builder with added tags.
-
tag
public Gauge.Builder<T> tag(java.lang.String key, java.lang.String value)
- Parameters:
key
- The tag key.value
- The tag value.- Returns:
- The gauge builder with a single added tag.
-
description
public Gauge.Builder<T> description(@Nullable java.lang.String description)
- Parameters:
description
- Description text of the eventual gauge.- Returns:
- The gauge builder with added description.
-
baseUnit
public Gauge.Builder<T> baseUnit(@Nullable java.lang.String unit)
- Parameters:
unit
- Base unit of the eventual gauge.- Returns:
- The gauge builder with added base unit.
-
synthetic
@Incubating(since="1.1.0") public Gauge.Builder<T> synthetic(Meter.Id syntheticAssociation)
For internal use. Marks a gauge as a derivative of another metric. For example, percentiles and histogram gauges generated byHistogramGauges
are derivatives of aTimer
orDistributionSummary
.This method may be removed in future minor or major releases if we find a way to mark derivatives in a private way that does not have other API compatibility consequences.
- Parameters:
syntheticAssociation
- The meter id of a meter for which this metric is a synthetic derivative.- Returns:
- The gauge builder with an added synthetic association.
-
strongReference
@Incubating(since="1.1.0") public Gauge.Builder<T> strongReference(boolean strong)
Indicates that the gauge should maintain a strong reference on the object upon which its instantaneous value is determined.- Parameters:
strong
- Whether or not to maintain a strong reference on the gauged object.- Returns:
- The gauge builder with altered strong reference semantics.
- Since:
- 1.1.0
-
register
public Gauge register(MeterRegistry registry)
Add the gauge to a single registry, or return an existing gauge in that registry. The returned gauge will be unique for each registry, but each registry is guaranteed to only create one gauge for the same combination of name and tags.- Parameters:
registry
- A registry to add the gauge to, if it doesn't already exist.- Returns:
- A new or existing gauge.
-
-