Class MetricsManager
java.lang.Object
com.j256.simplemetrics.manager.MetricsManager
Class which manages the various metrics that are in the system so they can be queried by operations. You register
metrics with this class, register classes that need to manually update metrics values, and controls the metrics
persistence.
- Author:
- graywatson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCollection<ControlledMetric<?, ?>> Return a map of the controlled metrics and their current associated values.String[]Map<ControlledMetric<?, ?>, Number> Return a map of the controlled metrics and their current associated values.intvoidpersist()Persists the configured metrics by calling to the registered updaters, extracting the value-details from the metrics, and then calling the registered value and details persisters.voidPersists the configured metrics to the value persisters only by extracting the values from the metrics and then calling the registered persisters.voidregisterMetric(ControlledMetric<?, ?> metric) Register a metric with the manager.voidregisterRegisterListener(MetricsRegisterListener registerListener) Register a listener for metrics registered and unregistered.voidregisterUpdater(MetricsUpdater metricsUpdater) Register aMetricsUpdaterto be called right before persist writes the metrics.voidsetMetricDetailsPersisters(MetricDetailsPersister[] metricDetailsPersisters) Set the persisters for the metric details.voidsetMetricValuesPersisters(MetricValuesPersister[] metricValuesPersisters) Set the persisters for the metric values.voidunregisterMetric(ControlledMetric<?, ?> metric) Unregister a metric with the manager.voidUpdate the various classes' metrics.
-
Constructor Details
-
MetricsManager
public MetricsManager()
-
-
Method Details
-
registerMetric
Register a metric with the manager. -
unregisterMetric
Unregister a metric with the manager. -
registerUpdater
Register aMetricsUpdaterto be called right before persist writes the metrics. -
registerRegisterListener
Register a listener for metrics registered and unregistered. -
persist
Persists the configured metrics by calling to the registered updaters, extracting the value-details from the metrics, and then calling the registered value and details persisters.- Throws:
IOException
-
persistValuesOnly
Persists the configured metrics to the value persisters only by extracting the values from the metrics and then calling the registered persisters. Usually you will want to callpersist()instead.NOTE: you should call updateMetrics() before calling this method if necessary.
- Throws:
IOException
-
getMetricValuesMap
Return a map of the controlled metrics and their current associated values. NOTE: this does not callupdateMetrics()beforehand. -
getMetricValueDetailsMap
Return a map of the controlled metrics and their current associated values. NOTE: this does not callupdateMetrics()beforehand. -
updateMetrics
public void updateMetrics()Update the various classes' metrics. -
getMetrics
- Returns:
- An unmodifiable collection of metrics we are managing.
-
setMetricValuesPersisters
Set the persisters for the metric values. -
setMetricDetailsPersisters
Set the persisters for the metric details. -
getMetricValues
-
getPersistCount
public int getPersistCount()
-