@ThreadSafe public interface DoubleValueRecorder extends SynchronousInstrument<DoubleValueRecorder.BoundDoubleValueRecorder>
ValueRecorder should be chosen either when capturing measurements that do not contribute meaningfully to a sum, or when capturing numbers that are additive in nature, but where the distribution of individual increments is considered interesting.
One of the most common uses for ValueRecorder is to capture latency measurements. Latency measurements are not additive in the sense that there is little need to know the latency-sum of all processed requests. We use a ValueRecorder instrument to capture latency measurements typically because we are interested in knowing mean, median, and other summary statistics about individual events.
Example:
class YourClass {
private static final Meter meter = OpenTelemetry.getMeterProvider().get("my_library_name");
private static final DoubleValueRecorder valueRecorder =
meter.
.doubleValueRecorderBuilder("doWork_latency")
.setDescription("gRPC Latency")
.setUnit("ms")
.build();
// It is recommended that the API user keep references to a Bound Counters.
private static final BoundDoubleValueRecorder someWorkBound =
valueRecorder.bind("work_name", "some_work");
void doWork() {
long startTime = System.nanoTime();
// Your code here.
someWorkBound.record((System.nanoTime() - startTime) / 1e6);
}
}
Modifier and Type | Interface and Description |
---|---|
static interface |
DoubleValueRecorder.BoundDoubleValueRecorder
A
Bound Instrument for a DoubleValueRecorder . |
static interface |
DoubleValueRecorder.Builder
Builder class for
DoubleValueRecorder . |
SynchronousInstrument.BoundInstrument
Modifier and Type | Method and Description |
---|---|
DoubleValueRecorder.BoundDoubleValueRecorder |
bind(Labels labels)
Returns a
Bound Instrument associated with the specified labels. |
void |
record(double value)
Records the given measurement, associated with the current
Context and empty labels. |
void |
record(double value,
Labels labels)
Records the given measurement, associated with the current
Context and provided set of
labels. |
void record(double value, Labels labels)
Context
and provided set of
labels.value
- the measurement to record.labels
- the set of labels to be associated to this recordingjava.lang.IllegalArgumentException
- if value is negative.void record(double value)
Context
and empty labels.value
- the measurement to record.java.lang.IllegalArgumentException
- if value is negative.DoubleValueRecorder.BoundDoubleValueRecorder bind(Labels labels)
SynchronousInstrument
Bound Instrument
associated with the specified labels. Multiples requests
with the same set of labels may return the same Bound Instrument
instance.
It is recommended that callers keep a reference to the Bound Instrument instead of always calling this method for every operation.
bind
in interface SynchronousInstrument<DoubleValueRecorder.BoundDoubleValueRecorder>
labels
- the set of labels, as key-value pairs.Bound Instrument