Example of how to send metrics to the log.#4218
Conversation
|
I'm torn on whether or not we should merge this. The IT doesn't really test anything, it uses MAC to generate the log entries. Maybe there is a better place to put this? Maybe we just mark the test as Disabled so that it doesn't increase the build times? |
|
I've been working on a Prometheus example for metrics that will live in accumulo-examples. I could expand that to also demo the LoggingMetrics. That way it would exist, but not be part of the code base. |
|
Ok, I'm fine with parking this here for now until we have somewhere to put it. |
|
Suggestion from @ctubbsii is to make this the reference implementation, but disabled by default. |
| */ | ||
| package org.apache.accumulo.test.metrics; | ||
|
|
||
| import org.apache.accumulo.core.metrics.MeterRegistryFactory; |
There was a problem hiding this comment.
I just noticed that the factory is in not in a public API package, or an SPI package. It should probably be in core/spi/metrics, not just core/metrics.
If users are expected to implement this SPI class, MeterRegistryFactory should be in the SPI package.
| * <p> | ||
| * Property.GENERAL_MICROMETER_FACTORY = TestLoggingRegistryFactory.class.getName() | ||
| */ | ||
| public class TestLoggingRegistryFactory implements MeterRegistryFactory { |
There was a problem hiding this comment.
I think this is a good basic implementation for a reference implementation. This class name could be set as the default value for the factory property, and this class could also live in the core/spi/metrics package.
I'd suggest renaming it to "BasicLoggingMeterRegistryFactory"
| cfg.setProperty(Property.GC_CYCLE_DELAY, "1s"); | ||
| cfg.setProperty(Property.MANAGER_FATE_METRICS_MIN_UPDATE_INTERVAL, "1s"); | ||
|
|
||
| // Tell the server processes to use a StatsDMeterRegistry that will be configured |
There was a problem hiding this comment.
This incorrectly says StatsD when its a Logging impl.
| // we need the test to take longer than 1m | ||
| for (int i = 0; i < 10; i++) { | ||
| doWorkToGenerateMetrics(); | ||
| Thread.sleep(10_000); |
| property.metricsFilename = ./target/test-metrics | ||
|
|
||
| # appender.metrics.type = Console | ||
| appender.metrics.type = RollingFile | ||
| appender.metrics.name = LoggingMetricsOutput | ||
| appender.metrics.fileName = ${metricsFilename}.metrics | ||
| appender.metrics.filePattern = ${metricsFilename}-%d{MM-dd-yy-HH}-%i.metrics.gz | ||
| appender.metrics.layout.type = PatternLayout | ||
| appender.metrics.layout.pattern = METRICS: %d{ISO8601}, %m%n | ||
| appender.metrics.policies.type = Policies | ||
| appender.metrics.policies.time.type = TimeBasedTriggeringPolicy | ||
| appender.metrics.policies.time.interval = 1 | ||
| appender.metrics.policies.time.modulate = true | ||
| appender.metrics.policies.size.type = SizeBasedTriggeringPolicy | ||
| appender.metrics.policies.size.size=100MB | ||
| appender.metrics.strategy.type = DefaultRolloverStrategy | ||
| appender.metrics.strategy.max = 10 | ||
|
|
||
| logger.metrics.name = org.apache.accumulo.metrics | ||
| logger.metrics.level = info | ||
| logger.metrics.additivity = false | ||
| logger.metrics.appenderRef.metrics.ref = LoggingMetricsOutput | ||
|
|
There was a problem hiding this comment.
👍 I love seeing this stuff go away from our config, even though it's just test config. I'm not really sure how it was previously being used, though.
There was a problem hiding this comment.
This was a vestige when metric logs were read / confirmed with a file tailer that has been removed.
|
Closing in favor of #4459 |
This adds an example of how to create a MeterRegistryFactory that
emits metrics to the log. In this example the metrics are emitted to
the process log every 1 minute using the logger name LoggingMeterRegistry.