Class MetricsServiceImpl
- java.lang.Object
-
- fish.payara.microprofile.metrics.impl.MetricsServiceImpl
-
- All Implemented Interfaces:
MetricsService,fish.payara.monitoring.collect.MonitoringDataSource,ConfigListener
@Service(name="microprofile-metrics-service") @RunLevel(10) public class MetricsServiceImpl extends Object implements MetricsService, ConfigListener, fish.payara.monitoring.collect.MonitoringDataSource
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface fish.payara.microprofile.metrics.MetricsService
MetricsService.MetricsContext
-
-
Constructor Summary
Constructors Constructor Description MetricsServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UnprocessedChangeEventschanged(PropertyChangeEvent[] events)Notification that @Configured objects that were injected have changedvoidcollect(fish.payara.monitoring.collect.MonitoringDataCollector rootCollector)voidderegisterApplication(String applicationName)Removes an application from the enabled mapStringgetApplicationName()Gets the application name from the invocation manager.MetricsService.MetricsContextgetContext(boolean createIfNotExists)Access current application metric context.MetricsService.MetricsContextgetContext(String name)Access the context by name.Set<String>getContextNames()voidinit()booleanisEnabled()When metrics are disabled noMetricsService.MetricsContextexists, bothMetricsService.getContext(boolean)andMetricsService.getContext(String)will return null.BooleanisMetricsSecure()booleanisSecurityEnabled()voidrefresh()Registers unresolved MBeans if they have been started after the metrics service.voidregisterApplication(String applicationName)Adds an application to the enabled mapvoidresetMetricsEnabledProperty()voidresetMetricsSecureProperty()
-
-
-
Method Detail
-
init
@PostConstruct public void init()
-
getContextNames
public Set<String> getContextNames()
- Specified by:
getContextNamesin interfaceMetricsService- 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 usingMetricsService.getContext(boolean).
-
getContext
public MetricsService.MetricsContext getContext(boolean createIfNotExists)
Description copied from interface:MetricsServiceAccess current application metric context. If this is called from a context that is not linked to an application context the server context is returned.- Specified by:
getContextin interfaceMetricsService- 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
MetricsService.isEnabled()
-
getContext
public MetricsService.MetricsContext getContext(String name)
Description copied from interface:MetricsServiceAccess the context by name. Implicitly creates theMetricsService.MetricsContext.SERVER_CONTEXT_NAMEif needed but no other context that does not exist yet or no more.- Specified by:
getContextin interfaceMetricsService- 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
MetricsService.isEnabled()no context exists. Otherwise when asking for theMetricsService.MetricsContext.SERVER_CONTEXT_NAMEthe context is created should it not exist yet.
-
collect
public void collect(fish.payara.monitoring.collect.MonitoringDataCollector rootCollector)
- Specified by:
collectin interfacefish.payara.monitoring.collect.MonitoringDataSource
-
refresh
public void refresh()
Registers unresolved MBeans if they have been started after the metrics service.- Specified by:
refreshin interfaceMetricsService
-
isEnabled
public boolean isEnabled()
Description copied from interface:MetricsServiceWhen metrics are disabled noMetricsService.MetricsContextexists, bothMetricsService.getContext(boolean)andMetricsService.getContext(String)will return null.- Specified by:
isEnabledin interfaceMetricsService- Returns:
- true if the metrics feature is generally enabled, else false
-
resetMetricsEnabledProperty
public void resetMetricsEnabledProperty()
-
isMetricsSecure
public Boolean isMetricsSecure()
-
resetMetricsSecureProperty
public void resetMetricsSecureProperty()
-
isSecurityEnabled
public boolean isSecurityEnabled()
-
registerApplication
public void registerApplication(String applicationName)
Adds an application to the enabled map- Parameters:
applicationName- The name of the application to create
-
deregisterApplication
public void deregisterApplication(String applicationName)
Removes an application from the enabled map- Parameters:
applicationName- The name of the application to remove
-
getApplicationName
public String getApplicationName()
Gets the application name from the invocation manager.- Returns:
- The application name
-
changed
public UnprocessedChangeEvents changed(PropertyChangeEvent[] events)
Description copied from interface:ConfigListenerNotification that @Configured objects that were injected have changed- Specified by:
changedin interfaceConfigListener- Parameters:
events- list of changes- Returns:
- the list of unprocessed events (requiring a restart) or null if all reconfiguration was processed successfully
-
-