Improve docs on custom metrics

See gh-12324
pull/12342/head
Jon Schneider 7 years ago committed by Andy Wilkinson
parent 3370c23ab9
commit 25ff82f1d7

@ -1749,9 +1749,25 @@ factories with a metric named `rabbitmq`.
[[production-ready-metrics-custom]] [[production-ready-metrics-custom]]
=== Registering custom metrics === Registering custom metrics
To register custom metrics, create a `MeterBinder` bean. By default, all `MeterBinder` To register custom metrics, inject `MeterRegistry` into your component:
beans will be automatically applied to the micrometer `MeterRegistry.Config`.
[source,java,indent=0]
----
class Dictionary {
private List<String> words = new CopyOnWriteArrayList<>();
public MyComponent(MeterRegistry registry) {
registry.gaugeCollectionSize("dictionary.size", Tags.empty(), words);
}
...
}
----
If you find that you repeatedly instrument a suite of metrics across components or
applications, you may encapsulate this suite in a `MeterBinder` implementation. By
default, metrics from all `MeterBinder` beans will be automatically bound to
the Spring-managed `MeterRegistry`.
[[production-ready-metrics-per-meter-properties]] [[production-ready-metrics-per-meter-properties]]

Loading…
Cancel
Save