Package fish.payara.microprofile.metrics
Interface MetricsService
-
- All Known Implementing Classes:
MetricsServiceImpl
@Contract public interface MetricsServiceThe API to useMetricRegistrys within an multi-application environment. The main purpose of this API is to cleanly decouple the users from the service provider and to avoid API pollution with methods that might be added to test or integrate the implementation but should not be called anywhere else.- Since:
- 5.2020.8
- Author:
- Jan Bernitt
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceMetricsService.MetricsContextEach deployed application has its ownMetricsService.MetricsContext.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MetricsService.MetricsContextgetContext(boolean createIfNotExists)Access current application metric context.MetricsService.MetricsContextgetContext(String name)Access the context by name.Set<String>getContextNames()booleanisEnabled()When metrics are disabled noMetricsService.MetricsContextexists, bothgetContext(boolean)andgetContext(String)will return null.voidrefresh()Triggers update of internal state usually used after configuration changes that can have the effect that metrics appear or disappear in a way that is detected by the registry.
-
-
-
Method Detail
-
isEnabled
boolean isEnabled()
When metrics are disabled noMetricsService.MetricsContextexists, bothgetContext(boolean)andgetContext(String)will return null.- Returns:
- true if the metrics feature is generally enabled, else false
-
refresh
void refresh()
Triggers update of internal state usually used after configuration changes that can have the effect that metrics appear or disappear in a way that is detected by the registry.
-
getContextNames
Set<String> getContextNames()
- Returns:
- a set of all
MetricsService.MetricsContextthat currently exist. When applications are undeployed theirMetricsService.MetricsContextequally are removed which means a name from the set of names returned may indeed no longer exists when usinggetContext(boolean).
-
getContext
MetricsService.MetricsContext getContext(boolean createIfNotExists)
Access current application metric context. If this is called from a context that is not linked to an application context the server context is returned.- Parameters:
createIfNotExists- true to create the requested context in case it did not exist, false to instead return null in that case- Returns:
- the existing or created context or null if it did not exist and parameter was false or if the servicenot
isEnabled()
-
getContext
MetricsService.MetricsContext getContext(String name)
Access the context by name. Implicitly creates theMetricsService.MetricsContext.SERVER_CONTEXT_NAMEif needed but no other context that does not exist yet or no more.- Parameters:
name- the name of theMetricsService.MetricsContextto provide, this assumes it does exist- Returns:
- the existing context or null if it does not (or no longer) exist. When the service not
isEnabled()no context exists. Otherwise when asking for theMetricsService.MetricsContext.SERVER_CONTEXT_NAMEthe context is created should it not exist yet.
-
-