public interface Metrics
A main entry point for developers to the Helidon metrics system, allowing access to the global meter registry and providing
shortcut methods to register and locate meters in the global registry and remove meters from it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic MeterRegistry
Creates a meter registry, not saved as the global registry, using default metrics config information based on global config.static MeterRegistry
createMeterRegistry
(MetricsConfig metricsConfig) Creates a meter registry, not saved as the global registry, based on the provided metrics config.Locates a previously-registered meter of the specified type, matching the name and tags.getCounter
(String name) Locates a previously-registerec counter.getCounter
(String name, Iterable<Tag> tags) Locates a previously-registered counter.Locates a previously-registered gauge.Locates a previously-registered gauge.static <M extends Meter,
B extends Meter.Builder<B, M>>
MgetOrCreate
(B builder) Locates a previously-registered meter using the name and tags in the provided builder or, if not found, registers a new one using the provided builder, both using the metrics factory's global registry.static Optional
<DistributionSummary> getSummary
(String name) Locates a previously-registered distribution summary.static Optional
<DistributionSummary> getSummary
(String name, Iterable<Tag> tags) Locates a previously-registered distribution summary.Locates a previously-registered timer.Locates a previously-registered timer.static MeterRegistry
Returns the global meter registry.static Tag
Creates aTag
for the specified key and value.
-
Method Details
-
globalRegistry
Returns the global meter registry.- Returns:
- the global meter registry
-
createMeterRegistry
Creates a meter registry, not saved as the global registry, based on the provided metrics config.- Parameters:
metricsConfig
- metrics config- Returns:
- new meter registry
-
createMeterRegistry
Creates a meter registry, not saved as the global registry, using default metrics config information based on global config.- Returns:
- new meter registry
-
getOrCreate
Locates a previously-registered meter using the name and tags in the provided builder or, if not found, registers a new one using the provided builder, both using the metrics factory's global registry.- Type Parameters:
M
- type of the meterB
- builder for the meter- Parameters:
builder
- builder to use in finding or creating a meter- Returns:
- the previously-registered meter with the same name and tags or, if none, the newly-registered one
-
getCounter
Locates a previously-registered counter.- Parameters:
name
- name to matchtags
- tags to match- Returns:
Optional
of the previously-registered counter; empty if not found
-
getCounter
Locates a previously-registerec counter.- Parameters:
name
- name to match- Returns:
Optional
of the previously-registered counter; empty if not found
-
getSummary
Locates a previously-registered distribution summary.- Parameters:
name
- name to matchtags
- tags to match- Returns:
Optional
of the previously-registered distribution summary; empty if not found
-
getSummary
Locates a previously-registered distribution summary.- Parameters:
name
- name to match- Returns:
Optional
of the previously-registered distribution summary; empty if not found
-
getGauge
Locates a previously-registered gauge.- Parameters:
name
- name to matchtags
- tags to match- Returns:
Optional
of the previously-registered gauge; empty if not found
-
getGauge
Locates a previously-registered gauge.- Parameters:
name
- name to match- Returns:
Optional
of the previously-registered gauge; empty if not found
-
getTimer
Locates a previously-registered timer.- Parameters:
name
- name to matchtags
- tags to match- Returns:
Optional
of the previously-registered timer; empty if not found
-
getTimer
Locates a previously-registered timer.- Parameters:
name
- name to match- Returns:
Optional
of the previously-registered timer; empty if not found
-
get
Locates a previously-registered meter of the specified type, matching the name and tags.The method throws an
IllegalArgumentException
if a meter exists with the name and tags but is not type-compatible with the provided class.- Type Parameters:
M
- type of the meter to find- Parameters:
mClass
- type of the meter to findname
- name to matchtags
- tags to match- Returns:
Optional
of the previously-regsitered meter; empty if not found
-
tag
Creates aTag
for the specified key and value.- Parameters:
key
- tag keyvalue
- tag value- Returns:
- new tag
-
tags
- Parameters:
keyValuePairs
- pairs of tag name/tag value pairs- Returns:
- tags corresponding to the tag name/tag value pairs
-