Interface Metrics
- All Known Implementing Classes:
MetricsRegistry,MicrometerMetrics,OtelMetrics
NOOP, which
records nothing and allocates nothing; a real implementation is installed with
Application.metrics(Metrics) before startup.
Lookup versus recording. counter(java.lang.String, java.lang.String...), gauge(java.lang.String, java.lang.String...) and timer(java.lang.String, java.lang.String...)
look an instrument up, or create it, by name and tags. They may allocate and take a lock, so
callers resolve instruments once and keep them; the runtime does. The recording methods of an
instrument are the hot path: implementations make them thread-safe, non-blocking and
allocation-free. The runtime never lets a failing instrument fail a request: a RuntimeException from any method is caught, reported once to System.Logger, and the
measurement is dropped.
Names and tags. A name is lowercase words separated by dots, for example
axiom.http.requests. Tags are given as alternating keys and values. Tag values must come
from a small, fixed set: route templates, HTTP methods and status classes, never raw request
paths, query strings, header values, identities or other user input. The runtime follows this
rule itself, and an implementation should bound the number of series it keeps (the registry in
axiom-metrics does) so that an application mistake cannot exhaust memory.
The same name and tags always identify the same series. The runtime's own metric names and tags are listed in the observability guide.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA monotonically increasing count.static interfaceA value that moves both ways.static interfaceA recorder of durations. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns the monotonically increasing counter for a series, creating it if needed.Returns the gauge for a series, creating it if needed.Optional Prometheus text exposition (format 0.0.4) of this implementation's series.Returns the timer for a series, creating it if needed.
-
Field Details
-
NOOP
Records nothing. Its instruments are shared, immutable and free of allocation.
-
-
Method Details
-
counter
Returns the monotonically increasing counter for a series, creating it if needed.- Parameters:
name- dotted lowercase metric nametags- alternating tag keys and values, possibly none- Returns:
- a thread-safe counter; never null
- Throws:
IllegalArgumentException- if the name or tags are invalid or conflict with the metric's earlier use
-
gauge
Returns the gauge for a series, creating it if needed. A gauge is a value that moves both ways, such as a queue depth. It is changed by deltas, so several components can share one series and the value stays the sum of their contributions.- Parameters:
name- dotted lowercase metric nametags- alternating tag keys and values, possibly none- Returns:
- a thread-safe gauge; never null
- Throws:
IllegalArgumentException- if the name or tags are invalid or conflict with the metric's earlier use
-
timer
Returns the timer for a series, creating it if needed. A timer records durations and keeps their distribution, so latency percentiles can be derived from it.- Parameters:
name- dotted lowercase metric nametags- alternating tag keys and values, possibly none- Returns:
- a thread-safe timer; never null
- Throws:
IllegalArgumentException- if the name or tags are invalid or conflict with the metric's earlier use
-
prometheusText
Optional Prometheus text exposition (format 0.0.4) of this implementation's series. The management listener's/metricsendpoint calls this on every scrape; the runtime caps the returned text at the configured response limit. The default is empty: an implementation that does not expose text serves an empty scrape.MetricsRegistryinaxiom-metricsoverrides this withPrometheusText.render(this); no rendering code or third-party type enters core.- Returns:
- exposition text, or empty when this implementation has no text form
-