Class MicrometerMetricFactory
java.lang.Object
com.gigaspaces.metrics.micrometer.MicrometerMetricFactory
Factory class for creating and managing Micrometer metrics (Timers, Counters, Gauges, etc.).
Provides static helper methods for obtaining metric instances with appropriate tags.
This is a generic utility that can be used across different contexts (aggregations, queries, transactions, etc.).
Available Metric Types:
- Timer - Measures duration of operations (latency). Use
getTimer(io.micrometer.core.instrument.MeterRegistry, io.micrometer.core.instrument.Tags, java.lang.String, java.lang.String, java.lang.String, java.lang.String)methods. - Counter - Cumulative count of events (monotonically increasing). Use
getCounter(io.micrometer.core.instrument.MeterRegistry, io.micrometer.core.instrument.Tags, java.lang.String, java.lang.String)methods.
Throughput Metrics:
For throughput (operations/second), use Counter metrics and let the monitoring system calculate the rate:- In PromQL:
rate(metric_name_total[1m])- operations per second over 1 minute - In Grafana: Use "Rate" function in queries
- Since:
- 17.1.4
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.micrometer.core.instrument.CountergetAggregationCounter(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, List<SpaceEntriesAggregator> aggregators) Convenience method: Gets or creates a Counter for aggregation operations with the aggregator type as a tag.static io.micrometer.core.instrument.TimergetAggregationTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, List<SpaceEntriesAggregator> aggregators) Convenience method: Gets or creates a Timer for aggregation operations with the aggregator type as a tag.static io.micrometer.core.instrument.CountergetCounter(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description) Gets or creates a generic Counter without any additional tags (only base tags).static io.micrometer.core.instrument.CountergetCounter(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description, io.micrometer.core.instrument.Tags additionalTags) Gets or creates a generic Counter with additional custom tags.static io.micrometer.core.instrument.CountergetCounter(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description, String tagKey, String tagValue) Gets or creates a generic Counter with a single custom tag.static io.micrometer.core.instrument.TimergetQueryTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String queryType) Convenience method: Gets or creates a Timer for query operations.static io.micrometer.core.instrument.TimergetTaskExecutionTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String taskName, boolean isDistributed) Convenience method: Gets or creates a Timer for task execution operations.static io.micrometer.core.instrument.TimergetTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description) Gets or creates a Timer without any additional tags (only base tags).static io.micrometer.core.instrument.TimergetTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description, io.micrometer.core.instrument.Tags additionalTags) Gets or creates a generic Timer with multiple custom tags.static io.micrometer.core.instrument.TimergetTransactionTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String transactionPhase) Convenience method: Gets or creates a Timer for transaction operations.
-
Method Details
-
getTimer
public static io.micrometer.core.instrument.Timer getTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description, io.micrometer.core.instrument.Tags additionalTags) Gets or creates a generic Timer with multiple custom tags. The timer is automatically registered with the provided MeterRegistry and will be reused for subsequent calls with the same parameters.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the timer withbaseTags- Base tags to apply to the timer (e.g., space_name, instance_id)metricName- Name of the timer metric (e.g., "space_query_duration")description- Description of what this timer measuresadditionalTags- Additional tags to apply (will be merged with baseTags)- Returns:
- Timer instance for recording duration, or null if meterRegistry is null
-
getTimer
public static io.micrometer.core.instrument.Timer getTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description) Gets or creates a Timer without any additional tags (only base tags).- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the timer withbaseTags- Base tags to apply to the timer (e.g., space_name, instance_id)metricName- Name of the timer metricdescription- Description of what this timer measures- Returns:
- Timer instance for recording duration, or null if meterRegistry is null
-
getCounter
public static io.micrometer.core.instrument.Counter getCounter(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description) Gets or creates a generic Counter without any additional tags (only base tags). Counters are cumulative metrics that only increase over time. The counter is automatically registered with the provided MeterRegistry and will be reused for subsequent calls with the same parameters.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the counter withbaseTags- Base tags to apply to the counter (e.g., space_name, instance_id)metricName- Name of the counter metricdescription- Description of what this counter measures- Returns:
- Counter instance for incrementing, or null if meterRegistry is null
-
getCounter
public static io.micrometer.core.instrument.Counter getCounter(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description, io.micrometer.core.instrument.Tags additionalTags) Gets or creates a generic Counter with additional custom tags. Counters are cumulative metrics that only increase over time. The counter is automatically registered with the provided MeterRegistry and will be reused for subsequent calls with the same parameters.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the counter withbaseTags- Base tags to apply to the counter (e.g., space_name, instance_id)metricName- Name of the counter metricdescription- Description of what this counter measuresadditionalTags- Additional tags to apply (will be merged with baseTags)- Returns:
- Counter instance for incrementing, or null if meterRegistry is null
-
getCounter
public static io.micrometer.core.instrument.Counter getCounter(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String metricName, String description, String tagKey, String tagValue) Gets or creates a generic Counter with a single custom tag. Counters are cumulative metrics that only increase over time. The counter is automatically registered with the provided MeterRegistry and will be reused for subsequent calls with the same parameters.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the counter withbaseTags- Base tags to apply to the counter (e.g., space_name, instance_id)metricName- Name of the counter metricdescription- Description of what this counter measurestagKey- The key for the custom tag (e.g., "operation_type", "status")tagValue- The value for the custom tag (e.g., "write", "success")- Returns:
- Counter instance for incrementing, or null if meterRegistry is null
-
getAggregationTimer
public static io.micrometer.core.instrument.Timer getAggregationTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, List<SpaceEntriesAggregator> aggregators) Convenience method: Gets or creates a Timer for aggregation operations with the aggregator type as a tag.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the timer withbaseTags- Base tags to apply to the timer (e.g., space_name, instance_id)aggregators- List of aggregators being executed- Returns:
- Timer instance for recording aggregation duration, or null if meterRegistry is null
-
getAggregationCounter
public static io.micrometer.core.instrument.Counter getAggregationCounter(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, List<SpaceEntriesAggregator> aggregators) Convenience method: Gets or creates a Counter for aggregation operations with the aggregator type as a tag.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the counter withbaseTags- Base tags to apply to the counter (e.g., space_name, instance_id)aggregators- List of aggregators being executed- Returns:
- Counter instance for counting aggregation operations, or null if meterRegistry is null
-
getQueryTimer
public static io.micrometer.core.instrument.Timer getQueryTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String queryType) Convenience method: Gets or creates a Timer for query operations.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the timer withbaseTags- Base tags to apply to the timerqueryType- Type of query (e.g., "sql", "template", "id")- Returns:
- Timer instance for recording query duration, or null if meterRegistry is null
-
getTransactionTimer
public static io.micrometer.core.instrument.Timer getTransactionTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String transactionPhase) Convenience method: Gets or creates a Timer for transaction operations.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the timer withbaseTags- Base tags to apply to the timertransactionPhase- Phase of transaction (e.g., "prepare", "commit", "rollback")- Returns:
- Timer instance for recording transaction duration, or null if meterRegistry is null
-
getTaskExecutionTimer
public static io.micrometer.core.instrument.Timer getTaskExecutionTimer(io.micrometer.core.instrument.MeterRegistry meterRegistry, io.micrometer.core.instrument.Tags baseTags, String taskName, boolean isDistributed) Convenience method: Gets or creates a Timer for task execution operations.- Parameters:
meterRegistry- The Micrometer MeterRegistry to register the timer withbaseTags- Base tags to apply to the timertaskName- Fully qualified name of the task classisDistributed- Whether this is a distributed task (true) or regular task (false)- Returns:
- Timer instance for recording task execution duration, or null if meterRegistry is null
-