Class DefaultMetrics

java.lang.Object
io.micrometer.core.instrument.MeterRegistry
io.micrometer.core.instrument.composite.CompositeMeterRegistry
services.moleculer.metrics.DefaultMetrics
All Implemented Interfaces:
Metrics, MoleculerLifecycle

public class DefaultMetrics extends io.micrometer.core.instrument.composite.CompositeMeterRegistry implements Metrics
  • Field Details

    • logger

      protected static final org.slf4j.Logger logger
    • registry

      protected final HashMap<String,Object> registry
    • binders

      protected final HashMap<Class<? extends io.micrometer.core.instrument.binder.MeterBinder>, io.micrometer.core.instrument.binder.MeterBinder> binders
    • reporters

      protected DropwizardReporters reporters
    • readLock

      protected final ReentrantReadWriteLock.ReadLock readLock
    • writeLock

      protected final ReentrantReadWriteLock.WriteLock writeLock
    • publishPercentileHistogram

      protected boolean publishPercentileHistogram
    • percentilePrecision

      protected int percentilePrecision
    • distributionStatisticBufferLength

      protected int distributionStatisticBufferLength
    • percentiles

      protected double[] percentiles
  • Constructor Details

    • DefaultMetrics

      public DefaultMetrics()
    • DefaultMetrics

      public DefaultMetrics(io.micrometer.core.instrument.MeterRegistry... registries)
  • Method Details

    • started

      public void started(ServiceBroker broker) throws Exception
      Specified by:
      started in interface MoleculerLifecycle
      Throws:
      Exception
    • increment

      public MetricCounter increment(String name, String description, double delta, String... tags)
      Specified by:
      increment in interface Metrics
    • set

      public MetricGauge set(String name, String description, double value, String... tags)
      Specified by:
      set in interface Metrics
    • timer

      public StoppableTimer timer(String name, String description, Duration duration, String... tags)
      Specified by:
      timer in interface Metrics
    • getMetric

      protected <T> T getMetric(String name, String[] tags, Supplier<T> factory)
    • startConsoleReporter

      public void startConsoleReporter()
      Starts ConsoleReporter. For simple benchmarks, Metrics comes with ConsoleReporter, which periodically reports all registered metrics to the console. The period time of the sampling is ONE MINUTE.
    • startConsoleReporter

      public void startConsoleReporter(long period, TimeUnit periodUnit)
      Starts ConsoleReporter. For simple benchmarks, Metrics comes with ConsoleReporter, which periodically reports all registered metrics to the console.
      Parameters:
      period - the amount of time between polls
      periodUnit - the unit for period
    • startCsvReporter

      public void startCsvReporter(String directory)
      Starts CsvReporter. For more complex benchmarks, Metrics comes with CsvReporter, which periodically appends to a set of .csv files in a given directory. The period time of the sampling is ONE SECOND.
      Parameters:
      directory - directory the directory in which the .csv files will be created
    • startCsvReporter

      public void startCsvReporter(long period, TimeUnit periodUnit, String directory)
      Starts CsvReporter. For more complex benchmarks, Metrics comes with CsvReporter, which periodically appends to a set of .csv files in a given directory.
      Parameters:
      period - the amount of time between polls
      periodUnit - the unit for period
      directory - directory the directory in which the .csv files will be created
    • startSlf4jReporter

      public void startSlf4jReporter()
      Starts Slf4jReporter. A reporter class for logging metrics values to a SLF4J Logge} periodically, similar to ConsoleReporter or CsvReporter, but using the SLF4J framework instead. The period time of the sampling is ONE MINUTE.
    • startSlf4jReporter

      public void startSlf4jReporter(long period, TimeUnit periodUnit)
      Starts Slf4jReporter. A reporter class for logging metrics values to a SLF4J Logge} periodically, similar to ConsoleReporter or CsvReporter, but using the SLF4J framework instead.
      Parameters:
      period - the amount of time between polls
      periodUnit - the unit for period
    • startSlf4jReporter

      public void startSlf4jReporter(long period, TimeUnit periodUnit, String loggerName)
      Starts Slf4jReporter. A reporter class for logging metrics values to a SLF4J Logge} periodically, similar to ConsoleReporter or CsvReporter, but using the SLF4J framework instead.
      Parameters:
      period - the amount of time between polls
      periodUnit - the unit for period
      loggerName - name of the logger (eg. "moleculer.metrics" or null)
    • reporters

      protected DropwizardReporters reporters()
    • addClassLoaderMetrics

      public void addClassLoaderMetrics()
    • addJvmMemoryMetrics

      public void addJvmMemoryMetrics()
    • addJvmGcMetrics

      public void addJvmGcMetrics()
    • addProcessorMetrics

      public void addProcessorMetrics()
    • addJvmThreadMetrics

      public void addJvmThreadMetrics()
    • addExecutorServiceMetrics

      public void addExecutorServiceMetrics(ExecutorService executor, String executorServiceName, String... tags)
    • addMetrics

      public void addMetrics(io.micrometer.core.instrument.binder.MeterBinder binder)
    • stopped

      public void stopped()
      Specified by:
      stopped in interface MoleculerLifecycle
    • isPublishPercentileHistogram

      public boolean isPublishPercentileHistogram()
    • setPublishPercentileHistogram

      public void setPublishPercentileHistogram(boolean publishPercentileHistogram)
    • getPercentilePrecision

      public int getPercentilePrecision()
    • setPercentilePrecision

      public void setPercentilePrecision(int percentilePrecision)
    • getDistributionStatisticBufferLength

      public int getDistributionStatisticBufferLength()
    • setDistributionStatisticBufferLength

      public void setDistributionStatisticBufferLength(int distributionStatisticBufferLength)
    • getPercentiles

      public double[] getPercentiles()
    • setPercentiles

      public void setPercentiles(double[] percentiles)