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
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micrometer.core.instrument.MeterRegistry
io.micrometer.core.instrument.MeterRegistry.Config, io.micrometer.core.instrument.MeterRegistry.More -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final HashMap<Class<? extends io.micrometer.core.instrument.binder.MeterBinder>, io.micrometer.core.instrument.binder.MeterBinder> protected intprotected static final org.slf4j.Loggerprotected intprotected double[]protected booleanprotected final ReentrantReadWriteLock.ReadLockprotected DropwizardReportersprotected final ReentrantReadWriteLock.WriteLockFields inherited from class io.micrometer.core.instrument.MeterRegistry
clockFields inherited from interface Metrics
ONE_SECOND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddExecutorServiceMetrics(ExecutorService executor, String executorServiceName, String... tags) voidvoidvoidvoidaddMetrics(io.micrometer.core.instrument.binder.MeterBinder binder) voidintprotected <T> Tintdouble[]booleanprotected DropwizardReportersvoidsetDistributionStatisticBufferLength(int distributionStatisticBufferLength) voidsetPercentilePrecision(int percentilePrecision) voidsetPercentiles(double[] percentiles) voidsetPublishPercentileHistogram(boolean publishPercentileHistogram) voidStarts ConsoleReporter.voidstartConsoleReporter(long period, TimeUnit periodUnit) Starts ConsoleReporter.voidstartCsvReporter(long period, TimeUnit periodUnit, String directory) Starts CsvReporter.voidstartCsvReporter(String directory) Starts CsvReporter.voidstarted(ServiceBroker broker) voidStarts Slf4jReporter.voidstartSlf4jReporter(long period, TimeUnit periodUnit) Starts Slf4jReporter.voidstartSlf4jReporter(long period, TimeUnit periodUnit, String loggerName) Starts Slf4jReporter.voidstopped()Methods inherited from class io.micrometer.core.instrument.composite.CompositeMeterRegistry
add, close, defaultHistogramConfig, getBaseTimeUnit, getRegistries, newCounter, newDistributionSummary, newFunctionCounter, newFunctionTimer, newGauge, newLongTaskTimer, newMeter, newTimeGauge, newTimer, removeMethods inherited from class io.micrometer.core.instrument.MeterRegistry
clear, config, counter, counter, find, forEachMeter, gauge, gauge, gauge, gauge, gaugeCollectionSize, gaugeMapSize, get, getConventionName, getConventionTags, getMeters, isClosed, meterRegistrationFailed, more, newLongTaskTimer, remove, remove, removeByPreFilterId, summary, summary, timer, timer
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
registry
-
binders
-
reporters
-
readLock
-
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
- Specified by:
startedin interfaceMoleculerLifecycle- Throws:
Exception
-
increment
-
set
-
timer
-
getMetric
-
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
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 pollsperiodUnit- the unit forperiod
-
startCsvReporter
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.csvfiles will be created
-
startCsvReporter
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 pollsperiodUnit- the unit forperioddirectory- directory the directory in which the.csvfiles 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
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 pollsperiodUnit- the unit forperiod
-
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.- Parameters:
period- the amount of time between pollsperiodUnit- the unit forperiodloggerName- name of the logger (eg. "moleculer.metrics" or null)
-
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:
stoppedin interfaceMoleculerLifecycle
-
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)
-