Class MetricsManager
/metrics management endpoint: resolves a consumer-provided Micrometer
MeterRegistry from the host bean store and renders a scrape payload.
Consistent with micrometer-core being a provided dependency and Juneau's
explicit-over-magic stance, this adapter strictly consumes a consumer-provided registry — it
never auto-registers a default. When no MeterRegistry bean is present it degrades cleanly
(returns null, which the endpoints surface as HTTP 501).
A Prometheus text scrape is produced when the resolved registry is a PrometheusMeterRegistry.
That type lives in the separate micrometer-registry-prometheus artifact which this module does
not depend on, so its scrape() method is invoked reflectively — keeping the
registry choice entirely the consumer's, with no extra dependency leaked here.
See Also:
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.micrometer.core.instrument.MeterRegistryresolveRegistry(RestContext context) Resolves the consumer-providedMeterRegistryfrom the host context's bean store.scrape(io.micrometer.core.instrument.MeterRegistry registry) Renders a Prometheus text scrape from the registry, if it is aPrometheusMeterRegistry.
-
Constructor Details
-
MetricsManager
public MetricsManager()
-
-
Method Details
-
resolveRegistry
Resolves the consumer-providedMeterRegistryfrom the host context's bean store.- Parameters:
context- The REST context whose bean store is searched. May benull .- Returns:
- The registry, or
null if none is registered (or the context isnull ).
-
scrape
Renders a Prometheus text scrape from the registry, if it is aPrometheusMeterRegistry.Invoked reflectively to avoid a hard dependency on
micrometer-registry-prometheus. Returnsnull when the registry isnull , is not a Prometheus registry, or does not expose a no-argscrape()method — the endpoints surface that as HTTP 501.- Parameters:
registry- The resolved registry, ornull .- Returns:
- The Prometheus exposition text, or
null if no scrape is available.
-