Interface MetricsPublishingService


  • @Experimental("Micrometer metrics is a new addition to Geode and the API may change")
    public interface MetricsPublishingService
    Publishes metrics managed by a MetricsSession.

    Geode discovers MetricsPublishingServices during system 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 session
         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

    Experimental: Micrometer metrics is a new addition to Geode and the API may change.

    See Also:
    Micrometer Documentation, Micrometer Concepts
    • Method Detail

      • start

        void start​(MetricsSession session)
        Invoked when a metrics session starts. A typical implementation will create a meter registry that can publish to an external monitoring system, and call MetricsSession.addSubregistry(MeterRegistry) to add that registry to the session.
        Parameters:
        session - the metrics session whose metrics this publishing service will publish
      • stop

        void stop​(MetricsSession session)
        Invoked when a metrics session stops. The implementation should call MetricsSession.removeSubregistry(MeterRegistry) to remove each meter registry it added to the session. The implementation should also clean up any other resources it allocated during
        Parameters:
        session - the metrics session whose metrics this publishing service was publishing start(MetricsSession).
      • getUrl

        default java.util.Optional<java.net.URL> getUrl()