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

Function perCallTracesAndMetrics

stats/opencensus/opencensus.go:98–114  ·  view source on GitHub ↗

perCallTracesAndMetrics records per call spans and metrics.

(err error, span *trace.Span, startTime time.Time, method string)

Source from the content-addressed store, hash-verified

96
97// perCallTracesAndMetrics records per call spans and metrics.
98func perCallTracesAndMetrics(err error, span *trace.Span, startTime time.Time, method string) {
99 s := status.Convert(err)
100 if span != nil {
101 span.SetStatus(trace.Status{Code: int32(s.Code()), Message: s.Message()})
102 span.End()
103 }
104 callLatency := float64(time.Since(startTime)) / float64(time.Millisecond)
105 ocstats.RecordWithOptions(context.Background(),
106 ocstats.WithTags(
107 tag.Upsert(keyClientMethod, removeLeadingSlash(method)),
108 tag.Upsert(keyClientStatus, canonicalString(s.Code())),
109 ),
110 ocstats.WithMeasurements(
111 clientAPILatency.M(callLatency),
112 ),
113 )
114}
115
116// unaryInterceptor handles per RPC context management. It also handles per RPC
117// tracing and stats by creating a top level call span and recording the latency

Callers 2

unaryInterceptorMethod · 0.85
streamInterceptorMethod · 0.85

Calls 5

ConvertFunction · 0.92
canonicalStringFunction · 0.85
CodeMethod · 0.80
MessageMethod · 0.80
removeLeadingSlashFunction · 0.70

Tested by

no test coverage detected