Interface DoubleValueRecorder
-
- All Superinterfaces:
Instrument
,SynchronousInstrument<BoundDoubleValueRecorder>
@ThreadSafe public interface DoubleValueRecorder extends SynchronousInstrument<BoundDoubleValueRecorder>
ValueRecorder is a synchronous instrument useful for recording any number, positive or negative. Values captured by a Record(value) are treated as individual events belonging to a distribution that is being summarized.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); } }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BoundDoubleValueRecorder
bind(Labels labels)
Returns aBound Instrument
associated with the specified labels.void
record(double value)
Records the given measurement, associated with the currentContext
and empty labels.void
record(double value, Labels labels)
Records the given measurement, associated with the currentContext
and provided set of labels.
-
-
-
Method Detail
-
record
void record(double value, Labels labels)
Records the given measurement, associated with the currentContext
and provided set of labels.- Parameters:
value
- the measurement to record.labels
- the set of labels to be associated to this recording- Throws:
IllegalArgumentException
- if value is negative.
-
record
void record(double value)
Records the given measurement, associated with the currentContext
and empty labels.- Parameters:
value
- the measurement to record.- Throws:
IllegalArgumentException
- if value is negative.
-
bind
BoundDoubleValueRecorder bind(Labels labels)
Description copied from interface:SynchronousInstrument
Returns aBound Instrument
associated with the specified labels. Multiples requests with the same set of labels may return the sameBound Instrument
instance.It is recommended that callers keep a reference to the Bound Instrument instead of always calling this method for every operation.
- Specified by:
bind
in interfaceSynchronousInstrument<BoundDoubleValueRecorder>
- Parameters:
labels
- the set of labels, as key-value pairs.- Returns:
- a
Bound Instrument
-
-