public class Summary extends SimpleCollector<Summary.Child>
Example of uses for Summaries include:
Example Summaries:
class YourClass {
static final Summary receivedBytes = Summary.build()
.name("requests_size_bytes").help("Request size in bytes.").register();
static final Summary requestLatency = Summary.build()
.name("requests_latency_seconds").help("Request latency in seconds.").register();
void processRequest(Request req) {
Summary.Timer requestTimer = requestLatency.startTimer();
try {
// Your code here.
} finally {
receivedBytes.observe(req.size());
requestTimer.observeDuration();
}
}
}
This would allow you to track request rate, average latency and average request size.Modifier and Type | Class and Description |
---|---|
static class |
Summary.Builder |
static class |
Summary.Child
The value of a single Summary.
|
static class |
Summary.Timer
Represents an event being timed.
|
Collector.MetricFamilySamples, Collector.Type
children, fullname, help, labelNames, noLabelsChild
METRIC_LABEL_NAME_RE, METRIC_NAME_RE, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_SECOND, RESERVED_METRIC_LABEL_NAME_RE
Modifier and Type | Method and Description |
---|---|
static Summary.Builder |
build()
Return a Builder to allow configuration of a new Summary.
|
List<Collector.MetricFamilySamples> |
collect()
Return all of the metrics of this Collector.
|
protected Summary.Child |
newChild()
Return a new child, workaround for Java generics limitations.
|
void |
observe(double amt)
Observe the given amount on the summary with no labels.
|
Summary.Timer |
startTimer()
Start a timer to track a duration on the summary with no labels.
|
clear, initializeNoLabelsChild, labels, remove, setChild
checkMetricLabelName, checkMetricName, doubleToGoString, register, register
public static Summary.Builder build()
protected Summary.Child newChild()
SimpleCollector
newChild
in class SimpleCollector<Summary.Child>
public void observe(double amt)
public Summary.Timer startTimer()
Call Summary.Timer.observeDuration()
at the end of what you want to measure the duration of.
Copyright © 2015. All rights reserved.