...
How to Add a Meter Registry when Starting a Server or Locator
To add a sub-registry to a server or locator:
- Implement a custom metrics publishing service and put it in a jar file.
- Configure the jar file to register your custom metrics publishing service.
- Add your jar to the classpath when you start a server or locator.
Implement a Custom Metrics Publishing Service
The new interface org.apache.geode.metrics.MetricsPublishingService
provides an additional way to publish metrics generated by Micrometer meters in the cache meter registry. Geode discovers implementations of MetricsPublishingService
during cache creation, using the standard Java ServiceLoader
mechanism.
...
Code Block | ||||
---|---|---|---|---|
| ||||
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); } } |
Package this class into a jar file.
Configure Your jar File to Register Your Custom Metrics Publishing Service
To make your service available for loading, add the following provider-configuration file in the resource directory of your application Jarjar file:
Code Block | ||||
---|---|---|---|---|
| ||||
META-INF/services/org.apache.geode.metrics.MetricsPublishingService |
...