Class MetricsReporterService

  • All Implemented Interfaces:
    org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

    public class MetricsReporterService
    extends java.lang.Object
    implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

    Manages the logging of metrics.

    You can configure the following parameters of the custom metrics reporter service:

    • metrics.reporter.<reporterName>.enabled - defines whether reporting of metrics should be enabled
    • metrics.reporter.<reporterName>.filter.* - defines the SpEL expressions used to filter the names of metrics reported periodically. The way of handling the multiple filters defined in properties is defined by given MetricsReporterFactory implementation
    • metrics.reporter.<reporterName>.period.seconds - defines the period (in seconds) how often metrics should be reported

    • Field Detail

      • METRICS_REPORTER_ENABLED

        public static final java.lang.String METRICS_REPORTER_ENABLED
        See Also:
        Constant Field Values
      • METRICS_REPORTER_FILTER

        public static final java.lang.String METRICS_REPORTER_FILTER
        See Also:
        Constant Field Values
      • METRICS_REPORTER_PERIOD_SECONDS

        public static final java.lang.String METRICS_REPORTER_PERIOD_SECONDS
        See Also:
        Constant Field Values
      • DEFAULT_METRICS_REPORTER_PERIOD_SECONDS_VALUE

        public static final java.time.Duration DEFAULT_METRICS_REPORTER_PERIOD_SECONDS_VALUE
      • DEFAULT_METRICS_REPORTER_FILTER_VALUE

        public static final java.lang.String DEFAULT_METRICS_REPORTER_FILTER_VALUE
        See Also:
        Constant Field Values
    • Constructor Detail

      • MetricsReporterService

        public MetricsReporterService​(com.codahale.metrics.MetricRegistry registry,
                                      java.lang.String reporterName,
                                      MetricsReporterFactory metricsReporterFactory)
        The constructor for the metric report service. The service will check the config properties and manage the reporter (start/stop/update)
        Parameters:
        registry - the metric registry that should be used to report metrics
        reporterName - name of the reporter - it is used to determine the properties that will be used to configure the reporter
        metricsReporterFactory - the factory that will create the reporter any time it is required
    • Method Detail

      • getReportingPeriod

        public java.time.Duration getReportingPeriod()
      • isReporterEnabled

        public boolean isReporterEnabled()
      • getReporterFilters

        public java.util.Map<java.lang.String,​java.lang.String> getReporterFilters()
      • createDefaultExecutor

        protected java.util.concurrent.ScheduledExecutorService createDefaultExecutor​(java.lang.String name,
                                                                                      java.lang.String tenantID)
      • afterPropertiesSet

        public void afterPropertiesSet()
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      • destroy

        public void destroy()
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean