Users can add @ExportMetric[Reader,Writer] to readers and writers that
they want to participate in the default exporter. There is also still an
@ActuatorMetricWriter that is used for the legacy (non-Java8) Gauge and
CounterServices.
@ -912,12 +912,18 @@ used by default if you are on Java 8 or if you are using Dropwizard metrics.
@@ -912,12 +912,18 @@ used by default if you are on Java 8 or if you are using Dropwizard metrics.
[[production-ready-metric-writers]]
=== Metric writers, exporters and aggregation
Spring Boot provides a couple of implementations of a marker interface called `Exporter`
which can be used to copy metric readings from the in-memory buffers to a place where they
can be analysed and displayed. Indeed, if you provide a `@Bean` that implements the
`MetricWriter` interface, then it will automatically be hooked up to an `Exporter` and fed
metric updates every 5 seconds (configured via `spring.metrics.export.delayMillis`) via a
`@Scheduled` annotation in `MetricRepositoryAutoConfiguration`.
Spring Boot provides a couple of implementations of a marker interface
called `Exporter` which can be used to copy metric readings from the
in-memory buffers to a place where they can be analysed and
displayed. Indeed, if you provide a `@Bean` that implements the
`MetricWriter` interface and mark it `@ExportMetricWriter`, then it
will automatically be hooked up to an `Exporter` and fed metric
updates every 5 seconds (configured via
`spring.metrics.export.delayMillis`) via a `@Scheduled` annotation in
`MetricRepositoryAutoConfiguration`. In addition, any `MetricReader`
that you define and mark as `@ExportMetricReader` will have its values
exported by the default exporter.
The default exporter is a `MetricCopyExporter` which tries to optimize
itself by not copying values that haven't changed since it was last
@ -939,19 +945,23 @@ name (or pattern for matching bean names).
@@ -939,19 +945,23 @@ name (or pattern for matching bean names).
AggregateMetricReader repository = new AggregateMetricReader(repository());
private MetricReader aggregatesMetricReader() {
AggregateMetricReader repository = new AggregateMetricReader(
globalMetricsForAggregation());
return repository;
}
----
@ -1105,6 +1119,10 @@ NOTE: the example above uses `MetricExportProperties` to inject and
@@ -1105,6 +1119,10 @@ NOTE: the example above uses `MetricExportProperties` to inject and
extract the key and prefix. This is provided to you as a convenience
by Spring Boot, and the defaults for that will be sensible.
NOTE: the `MetricReaders` above are not `@Beans` and are not marked as
`@ExportMetricReader` because they are just collecting and analysing
data from other repositories, and don't want to export their values.