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 UnprocessedChangeEvents
changed(PropertyChangeEvent[] events)
Notification that @Configured objects that were injected have changedvoid
collect(fish.payara.monitoring.collect.MonitoringDataCollector rootCollector)
void
deregisterApplication(String applicationName)
Removes an application from the enabled mapString
getApplicationName()
Gets the application name from the invocation manager.MetricsService.MetricsContext
getContext(boolean createIfNotExists)
Access current application metric context.MetricsService.MetricsContext
getContext(String name)
Access the context by name.Set<String>
getContextNames()
void
init()
boolean
isEnabled()
When metrics are disabled noMetricsService.MetricsContext
exists, bothMetricsService.getContext(boolean)
andMetricsService.getContext(String)
will return null.Boolean
isMetricsSecure()
boolean
isSecurityEnabled()
void
refresh()
Registers unresolved MBeans if they have been started after the metrics service.void
registerApplication(String applicationName)
Adds an application to the enabled mapvoid
resetMetricsEnabledProperty()
void
resetMetricsSecureProperty()
-
-
-
Method Detail
-
init
@PostConstruct public void init()
-
getContextNames
public Set<String> getContextNames()
- Specified by:
getContextNames
in interfaceMetricsService
- Returns:
- a set of all
MetricsService.MetricsContext
that currently exist. When applications are undeployed theirMetricsService.MetricsContext
equally 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:MetricsService
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.- Specified by:
getContext
in 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:MetricsService
Access the context by name. Implicitly creates theMetricsService.MetricsContext.SERVER_CONTEXT_NAME
if needed but no other context that does not exist yet or no more.- Specified by:
getContext
in interfaceMetricsService
- Parameters:
name
- the name of theMetricsService.MetricsContext
to 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_NAME
the context is created should it not exist yet.
-
collect
public void collect(fish.payara.monitoring.collect.MonitoringDataCollector rootCollector)
- Specified by:
collect
in interfacefish.payara.monitoring.collect.MonitoringDataSource
-
refresh
public void refresh()
Registers unresolved MBeans if they have been started after the metrics service.- Specified by:
refresh
in interfaceMetricsService
-
isEnabled
public boolean isEnabled()
Description copied from interface:MetricsService
When metrics are disabled noMetricsService.MetricsContext
exists, bothMetricsService.getContext(boolean)
andMetricsService.getContext(String)
will return null.- Specified by:
isEnabled
in 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:ConfigListener
Notification that @Configured objects that were injected have changed- Specified by:
changed
in interfaceConfigListener
- Parameters:
events
- list of changes- Returns:
- the list of unprocessed events (requiring a restart) or null if all reconfiguration was processed successfully
-
-