Class MicrometerMetricManager

java.lang.Object
com.gigaspaces.metrics.micrometer.MicrometerMetricManager
All Implemented Interfaces:
Closeable, AutoCloseable

public class MicrometerMetricManager extends Object implements Closeable
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
  • Method Details

    • acquire

      public static MicrometerMetricManager 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

      public MetricRegistrator createRegistrator(String prefix)
      Create a registrator with a prefix.
    • createRegistrator

      public MetricRegistrator createRegistrator(String prefix, Map<String,String> tags)
      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

      public String getSeparator()
      Get the path separator used for metric names.
    • toPath

      public String toPath(String... names)
      Convert metric name components to a path string. Aligns with MetricManager.toPath behavior.
    • toPath

      public String toPath(String[] names, int limit)
      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

      public MetricFlagsState getMetricFlagsState()
      Get metric flags state for controlling which metrics are enabled. In Micrometer adapter, all flags are enabled by default.
    • getSnapshotsByPrefix

      public Map<String,Object> getSnapshotsByPrefix(Collection<String> prefixes)
      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

      public List<MetricRegistrator> registerProcessMetrics(Map<String,String> tags)
      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

      public MetricRegistrator registerOsMetrics(Map<String,String> tags)
      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 public boolean isMetricReporterDefined(String metricReporterClassName)
      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

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException