perCallTracesAndMetrics records per call spans and metrics.
(err error, span *trace.Span, startTime time.Time, method string)
| 96 | |
| 97 | // perCallTracesAndMetrics records per call spans and metrics. |
| 98 | func 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 |
no test coverage detected