August 2019
Intermediate to advanced
256 pages
6h 43m
English
A histogram is a type of metric that samples the distribution of data. It is mostly used to record the distribution of the time it takes to execute the decorated method. Histograms cannot be declared via dedicated annotation, unlike other types, but a timer, for example, includes histogram data. To use a histogram on its own, you need to register and update it in code:
// Register the Histogram@Inject@Metric(absolute = true)private Histogram aHistogram;// Update with a value from 0 to 10@GET@Path("/h")public String getHistogram() { aHistogram.update((int) (Math.random() * 10.0)); return "Histogram called";}
This way of using metrics in code is feasible for the other types as well.
Read now
Unlock full access