MCPcopy
hub / github.com/grpc/grpc-go / CallMetricsRecorderFromContext

Function CallMetricsRecorderFromContext

orca/call_metrics.go:58–64  ·  view source on GitHub ↗

CallMetricsRecorderFromContext returns the RPC-specific custom metrics recorder embedded in the provided RPC context. Returns nil if no custom metrics recorder is found in the provided context, which will be the case when custom metrics reporting is not enabled.

(ctx context.Context)

Source from the content-addressed store, hash-verified

56// Returns nil if no custom metrics recorder is found in the provided context,
57// which will be the case when custom metrics reporting is not enabled.
58func CallMetricsRecorderFromContext(ctx context.Context) CallMetricsRecorder {
59 rw, ok := ctx.Value(callMetricsRecorderCtxKey{}).(*recorderWrapper)
60 if !ok {
61 return nil
62 }
63 return rw.recorder()
64}
65
66// recorderWrapper is a wrapper around a CallMetricsRecorder to ensure that
67// concurrent calls to CallMetricsRecorderFromContext() results in only one

Callers 7

UnaryCallMethod · 0.92
startServerFunction · 0.92
UnaryEchoMethod · 0.92
TestWRRMetricsMethod · 0.92

Calls 2

recorderMethod · 0.80
ValueMethod · 0.45

Tested by 5

startServerFunction · 0.74
TestWRRMetricsMethod · 0.74