@Experimental(value="Micrometer metrics is a new addition to Geode and the API may change") public interface MetricsPublishingService
Geode discovers MetricsPublishingService
s during cache creation, using the standard Java
ServiceLoader
mechanism:
package com.application; public class MyMetricsPublishingService implements MetricsPublishingService { private volatile MeterRegistry registry; private volatile MetricsSession session; @Override public void start(MetricsSession session) { this.session = session; registry = ... // configure your meter registry and start publishing // add your registry as a sub-registry to the cache's composite registry session.addSubregistry(registry); } @Override public void stop() { ... // clean up any resources used by your meter registry ... session.removeSubregistry(registry); } }
To make your service available for loading, add the following provider-configuration file in the resource directory of your application Jar:
META-INF/services/org.apache.geode.metrics.MetricsPublishingService
Add a line inside the file indicating the fully qualified class name of your implementation:
com.application.MyMetricsPublishingService
Modifier and Type | Method and Description |
---|---|
void |
start(MetricsSession session)
Invoked when a metrics session is started during cache initialization.
|
void |
stop()
Invoked when a metrics session is stopped during cache close.
|
void start(MetricsSession session)
session
- the metrics session that is used to connect sub-registriesvoid stop()