Package io.opentelemetry.api.metrics
Interface DoubleValueObserver
-
- All Superinterfaces:
AsynchronousInstrument<AsynchronousInstrument.DoubleResult>
,Instrument
@ThreadSafe public interface DoubleValueObserver extends AsynchronousInstrument<AsynchronousInstrument.DoubleResult>
ValueObserver
is the asynchronous instrument corresponding to ValueRecorder, used to capture values that are treated as individual observations, recorded with the observe(value) method.A
ValueObserver
is a good choice in situations where a measurement is expensive to compute, such that it would be wasteful to compute on every request.Example:
class YourClass { private static final Meter meter = OpenTelemetry.getMeterProvider().get("my_library_name"); private static final DoubleValueObserver cpuObserver = meter. .doubleValueObserverBuilder("cpu_temperature") .setDescription("System CPU temperature") .setUnit("ms") .build(); void init() { cpuObserver.setCallback( new DoubleValueObserver.Callback<DoubleResult>() { {@literal @}Override public void update(DoubleResult result) { // Get system cpu temperature result.observe(cpuTemperature); } }); } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DoubleValueObserver.Builder
Builder class forDoubleValueObserver
.-
Nested classes/interfaces inherited from interface io.opentelemetry.api.metrics.AsynchronousInstrument
AsynchronousInstrument.Callback<R extends AsynchronousInstrument.Result>, AsynchronousInstrument.DoubleResult, AsynchronousInstrument.LongResult, AsynchronousInstrument.Result
-
-
Method Summary
-
Methods inherited from interface io.opentelemetry.api.metrics.AsynchronousInstrument
setCallback
-
-