50.10 Dropwizard Metrics
A default MetricRegistry
Spring bean will be created when you declare a dependency to the io.dropwizard.metrics:metrics-core
library; you can also register you own @Bean
instance if you need customizations. Users of the Dropwizard ‘Metrics’ library will find that Spring Boot metrics are automatically published to com.codahale.metrics.MetricRegistry
. Metrics from the MetricRegistry
are also automatically exposed via the /metrics
endpoint
When Dropwizard metrics are in use, the default CounterService
and GaugeService
are replaced with a DropwizardMetricServices
, which is a wrapper around the MetricRegistry
(so you can @Autowired
one of those services and use it as normal). You can also create “special” Dropwizard metrics by prefixing your metric names with the appropriate type (i.e. timer.*
, histogram.*
for gauges, and meter.*
for counters).