Refactor PublicMetrics registration

Rework flexible PublicMetrics registration introduced in 2be6b3e4 to
restore compatibility with v1.1 VanillaPublicMetrics. The new
MetricReaderPublicMetrics class now exposes metrics from a MetricReader
and VanillaPublicMetrics is deprecated. The MetricsEndpoint can now
exposes a collection of PublicMetric interface directly.

See gh-1094
This commit is contained in:
Phillip Webb
2014-07-29 12:31:40 -07:00
parent 8e0b3dd00a
commit 14c6243637
11 changed files with 254 additions and 99 deletions

View File

@@ -585,12 +585,12 @@ Spring Boot Actuator includes a metrics service with ``gauge'' and ``counter'' s
A ``gauge'' records a single value; and a ``counter'' records a delta (an increment or
decrement). Spring Boot Actuator also provides a
{sc-spring-boot-actuator}/endpoint/PublicMetrics.{sc-ext}[`PublicMetrics`] interface that
you can implement to expose metrics that you cannot record via one of those two mechanisms. Look
at {sc-spring-boot-actuator}/endpoint/SystemPublicMetrics.{sc-ext}[`SystemPublicMetrics`]
you can implement to expose metrics that you cannot record via one of those two
mechanisms. Look at {sc-spring-boot-actuator}/endpoint/SystemPublicMetrics.{sc-ext}[`SystemPublicMetrics`]
for an example.
Metrics for all HTTP requests are automatically recorded, so if you hit the
`metrics` endpoint you should see a response similar to this:
Metrics for all HTTP requests are automatically recorded, so if you hit the `metrics`
endpoint you should see a response similar to this:
[source,json,indent=0]
----
@@ -668,15 +668,17 @@ TIP: You can use any string as a metric name but you should follow guidelines of
store/graphing technology. Some good guidelines for Graphite are available on
http://matt.aimonetti.net/posts/2013/06/26/practical-guide-to-graphite-monitoring/[Matt Aimonetti's Blog].
[[production-ready-public-metrics]]
=== Adding your own public metrics
To add additional metrics that are computed every time the metrics endpoint is invoked,
simply register additional `PublicMetrics` implementation bean(s). By default, all such
beans are gathered by the endpoint. You can easily change that by defining your own
`MetricsEndpoint`.
[[production-ready-metric-repositories]]
=== Metric repositories
Metric service implementations are usually bound to a