@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/6012") @ThreadSafe public final class CallMetricRecorder extends Object
Modifier and Type | Method and Description |
---|---|
static CallMetricRecorder |
getCurrent()
Returns the call metric recorder attached to the current
Context . |
CallMetricRecorder |
recordCallMetric(String name,
double value)
Records a call metric measurement.
|
public static CallMetricRecorder getCurrent()
Context
. If there is none,
returns a no-op recorder.
IMPORTANT:It returns the recorder specifically for the current RPC call. DO NOT save the returned object or share it between different RPC calls.
IMPORTANT:It must be called under the Context
under which the RPC
handler was called. If it is called from a different thread, the Context must be propagated to
the same thread, e.g., with Context.wrap(Runnable)
.
public CallMetricRecorder recordCallMetric(String name, double value)
A latter record will overwrite its former name-sakes.