Distribution Summary¶
See Distribution Summary for the concept.
Distribution Summaries are created using the Registry, which will be set up as part of application initialization. For example:
public class Server {
private final DistributionSummary requestSize;
@Inject
public Server(Registry registry) {
requestSize = registry.distributionSummary("server.requestSize");
}
Then call record when an event occurs:
public Response handle(Request request) {
requestSize.record(request.sizeInBytes());
}
}
Batch Updates¶
For very high-volume updates within a single thread, DistributionSummary exposes a
batchUpdater that buffers updates and flushes them as a single operation. See
Performance Tips for the cross-cutting guidance and
Counter.batchUpdater for an annotated example.
Percentile Distribution Summary¶
Use a regular Distribution Summary unless percentile estimates are required.
Create one via the static builder:
public class Server {
private final PercentileDistributionSummary requestSize;
@Inject
public Server(Registry registry) {
requestSize = PercentileDistributionSummary.builder(registry)
.withId(registry.createId("server.requestSize"))
.build();
}
public void onRequest(Request request) {
requestSize.record(request.bodyBytes());
}
}
The builder also accepts a range via withRange(min, max) to bound the bucket set and reduce
storage overhead — see the
Javadoc
for details.