Package io.micrometer.core.instrument
Class HighCardinalityTagsDetector
java.lang.Object
io.micrometer.core.instrument.HighCardinalityTagsDetector
- All Implemented Interfaces:
AutoCloseable
Tries to detect high cardinality tags by checking if the amount of Meters with the same
name is above a threshold. This mechanism will not detect if you have other
memory-usage-related issues, like appending random values to the name of the Meters,
the only purpose of this class is detecting the potential presence of high cardinality
tags. You can use this class in two ways:
- Call findFirst and check if you get any results, if so you probably have high cardinality tags
- Call start which will start a scheduled job that will do this check for you.
MeterFilter.maximumAllowableTags(String, String, int, MeterFilter)
and
MeterFilter.maximumAllowableMetrics(int)
to set an upper bound on the number of
tags/metrics.- Since:
- 1.10.0
-
Constructor Summary
ConstructorDescriptionHighCardinalityTagsDetector
(MeterRegistry registry) HighCardinalityTagsDetector
(MeterRegistry registry, long threshold, Duration delay) HighCardinalityTagsDetector
(MeterRegistry registry, long threshold, Duration delay, Consumer<String> meterNameConsumer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Finds the name of the first Meter that potentially has high cardinality tags.void
shutdown()
Shuts down the scheduled job that checks if you have high cardinality tags.void
start()
Starts a scheduled job that checks if you have high cardinality tags.
-
Constructor Details
-
HighCardinalityTagsDetector
- Parameters:
registry
- The registry to use to check the Meters in it
-
HighCardinalityTagsDetector
- Parameters:
registry
- The registry to use to check the Meters in itthreshold
- The threshold to use to detect high cardinality tags (if the number of Meters with the same name is higher than this value, that's a high cardinality tag)delay
- The delay between the termination of one check and the commencement of the next
-
HighCardinalityTagsDetector
public HighCardinalityTagsDetector(MeterRegistry registry, long threshold, Duration delay, @Nullable Consumer<String> meterNameConsumer) - Parameters:
registry
- The registry to use to check the Meters in itthreshold
- The threshold to use to detect high cardinality tags (if the number of Meters with the same name is higher than this value, that's a high cardinality tag)delay
- The delay between the termination of one check and the commencement of the nextmeterNameConsumer
- The action to execute if the first high cardinality tag is found
-
-
Method Details
-
start
public void start()Starts a scheduled job that checks if you have high cardinality tags. -
shutdown
public void shutdown()Shuts down the scheduled job that checks if you have high cardinality tags. -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
findFirst
Finds the name of the first Meter that potentially has high cardinality tags.- Returns:
- the name of the first Meter that potentially has high cardinality tags, an empty Optional if none found.
-