Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

How to Add a Meter Registry when Starting a Server or Locator

To add a sub-registry to a server or locator:

  1. Implement a custom metrics publishing service and put it in a jar file.
  2. Configure the jar file to register your custom metrics publishing service.
  3. 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
languagejava
themeRDark
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
languagetext
themeRDark
META-INF/services/org.apache.geode.metrics.MetricsPublishingService

...