public class Main extends Object
This Maven module demonstrates Prometheus integration with Google's Guice framework as
well as more advanced use of prepopulated Metric.Builder
and Metric.Partial constructs.
In this case, we demonstrate optional provisioning of Metric
through Guice Provider in Module. What is
interesting to note is that we have a fictional HTTP server with two HTTP Servlet handlers that share the same two fundamental metrics defined in Module.HandlerCounterProvider and Module.HandlerLatencyProvider. These two metrics
track a typical use case of measuring request counts and latency quantiles. The metrics share
the same schema and metric name, but the handlers can be differentiated by label values
.
This example is unremarkable in the sense that manual passing of partially-fabricated metrics is possible to do by hand as well, and it is easy. In the interests of minimizing static state and promoting testability, teams may decide to use dependency injection for provisioning of metrics that are shared between multiple classes, though this is discouraged since except for a few rare cases it demonstrates violation of law of demeter and separation of concerns .
Copyright © 2014. All Rights Reserved.