Class MicrometerMetricManager
java.lang.Object
com.gigaspaces.metrics.micrometer.MicrometerMetricManager
- All Implemented Interfaces:
Closeable,AutoCloseable
Micrometer-based implementation of metric management.
This class serves as an adapter/facade to Micrometer's MeterRegistry,
allowing gradual migration from the custom metrics system.
Usage:
MicrometerMetricManager manager = MicrometerMetricManager.acquire();
MetricRegistrator registrator = manager.createRegistrator("myprefix");
registrator.register("counter", new LongCounter());
- Since:
- 17.1.4
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassInner class for metric flags state. -
Method Summary
Modifier and TypeMethodDescriptionstatic MicrometerMetricManageracquire()Acquire the singleton instance with reference counting.static MicrometerMetricManageracquire(io.micrometer.core.instrument.MeterRegistry customRegistry) Acquire instance with a custom MeterRegistry.voidclose()createRegistrator(String prefix) Create a registrator with a prefix.createRegistrator(String prefix, Map<String, String> tags) Create a registrator with a prefix and additional tags.createRegistrator(String prefix, Map<String, String> tags, Map<String, DynamicMetricTag> dynamicTags) Create a registrator with a prefix, tags, and dynamic tags.io.micrometer.core.instrument.TagsGet default tags applied to all metrics.io.micrometer.core.instrument.MeterRegistryGet the underlying MeterRegistry for advanced usage.Get metric flags state for controlling which metrics are enabled.Get the path separator used for metric names.getSnapshotsByPrefix(Collection<String> prefixes) Get snapshots of metrics by prefix.getSnapshotsByPrefixAndMatchingTags(Collection<String> prefixes, MetricTags tags) Get snapshots of metrics by prefix and matching tags.booleanisMetricReporterDefined(String metricReporterClassName) Deprecated.This method exists for backward compatibility onlyregisterOsMetrics(Map<String, String> tags) Register OS-level metrics (CPU, memory, swap, network).registerProcessMetrics(Map<String, String> tags) Register process metrics (CPU, memory, etc.) along with JVM and LRMI metrics.static voidregisterTaskManagerMetrics(MetricRegistrator registrator, TaskManager taskManager) Register task manager metrics.static voidregisterThreadPoolMetrics(MetricRegistrator registrator, DynamicThreadPoolExecutor dynamicThreadPoolExecutor) Register thread pool metrics for a DynamicThreadPoolExecutor.Convert metric name components to a path string.Convert metric name components to a path string with a limit.
-
Method Details
-
acquire
Acquire the singleton instance with reference counting. -
acquire
public static MicrometerMetricManager acquire(io.micrometer.core.instrument.MeterRegistry customRegistry) Acquire instance with a custom MeterRegistry. Useful for testing or custom registry configurations. -
createRegistrator
Create a registrator with a prefix. -
createRegistrator
Create a registrator with a prefix and additional tags. -
createRegistrator
public MetricRegistrator createRegistrator(String prefix, Map<String, String> tags, Map<String, DynamicMetricTag> dynamicTags) Create a registrator with a prefix, tags, and dynamic tags. Dynamic tags are evaluated at metric registration time to get their current values. -
getMeterRegistry
public io.micrometer.core.instrument.MeterRegistry getMeterRegistry()Get the underlying MeterRegistry for advanced usage. -
getSeparator
Get the path separator used for metric names. -
toPath
Convert metric name components to a path string. Aligns with MetricManager.toPath behavior. -
toPath
Convert metric name components to a path string with a limit. Aligns with MetricManager.toPath behavior. -
getDefaultTags
public io.micrometer.core.instrument.Tags getDefaultTags()Get default tags applied to all metrics. -
getMetricFlagsState
Get metric flags state for controlling which metrics are enabled. In Micrometer adapter, all flags are enabled by default. -
getSnapshotsByPrefix
Get snapshots of metrics by prefix. Retrieves current values of all metrics matching the given prefixes. -
getSnapshotsByPrefixAndMatchingTags
public Map<String,Object> getSnapshotsByPrefixAndMatchingTags(Collection<String> prefixes, MetricTags tags) Get snapshots of metrics by prefix and matching tags. Mimics MetricManager.getSnapshotsByPrefixAndMatchingTags behavior. -
registerProcessMetrics
Register process metrics (CPU, memory, etc.) along with JVM and LRMI metrics. This is the main entry point called by components like SpaceEngine, GSA, etc.- Parameters:
tags- Additional tags to add to all process metrics- Returns:
- List of MetricRegistrators for the registered metrics
-
registerOsMetrics
Register OS-level metrics (CPU, memory, swap, network). This is typically called only for GSA process.- Parameters:
tags- Additional tags to add to all OS metrics- Returns:
- MetricRegistrator for the registered metrics
-
registerThreadPoolMetrics
public static void registerThreadPoolMetrics(MetricRegistrator registrator, DynamicThreadPoolExecutor dynamicThreadPoolExecutor) Register thread pool metrics for a DynamicThreadPoolExecutor. Tracks active threads, queue size, pool size, and completed tasks. -
registerTaskManagerMetrics
public static void registerTaskManagerMetrics(MetricRegistrator registrator, TaskManager taskManager) Register task manager metrics. Tracks thread count and total tasks. -
isMetricReporterDefined
Deprecated.This method exists for backward compatibility only/** For backward compatibility with legacy MetricManager. In Micrometer, we don't use the old reporter pattern, so this always returns false.- Parameters:
metricReporterClassName- The class name of the reporter to check- Returns:
- false (reporters are not used in Micrometer implementation)
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-