MCPcopy Create free account
hub / github.com/couchbase/cbft / updateRpcFocusStats

Function updateRpcFocusStats

grpc_util.go:282–322  ·  view source on GitHub ↗
(startTime time.Time, mgr *cbgt.Manager,
	req *pb.SearchRequest, ctx context.Context, err error)

Source from the content-addressed store, hash-verified

280}
281
282func updateRpcFocusStats(startTime time.Time, mgr *cbgt.Manager,
283 req *pb.SearchRequest, ctx context.Context, err error) {
284 focusStats := GrpcPathStats.FocusStats(req.IndexName)
285 if focusStats != nil {
286 // check whether its a client request and track only in the coordinating node
287 if _, er := extractMetaHeader(ctx, rpcClusterActionKey); er != nil {
288 // co-ordinating node
289 atomic.AddUint64(&focusStats.TotGrpcRequest, 1)
290 atomic.AddUint64(&focusStats.TotGrpcRequestTimeNS,
291 uint64(time.Now().Sub(startTime)))
292
293 slowQueryLogTimeoutV := mgr.Options()["slowQueryLogTimeout"]
294 if slowQueryLogTimeoutV != "" {
295 var slowQueryLogTimeout time.Duration
296 slowQueryLogTimeout, err = time.ParseDuration(slowQueryLogTimeoutV)
297 if err == nil {
298 d := time.Since(startTime)
299 if d > slowQueryLogTimeout {
300 log.Warnf("grpc_util: slow-query index: %s,"+
301 " query: %s, duration: %v, err: %v",
302 req.IndexName, string(req.Contents), d, err)
303
304 atomic.AddUint64(&focusStats.TotGrpcRequestSlow, 1)
305 }
306 }
307 }
308
309 if err != nil {
310 atomic.AddUint64(&focusStats.TotGrpcRequestErr, 1)
311 if err == context.DeadlineExceeded {
312 atomic.AddUint64(&focusStats.TotGrpcRequestTimeout, 1)
313 }
314 }
315 } else {
316 // not a co-ordinating node
317 atomic.AddUint64(&focusStats.TotGrpcInternalRequest, 1)
318 atomic.AddUint64(&focusStats.TotGrpcInternalRequestTimeNS,
319 uint64(time.Now().Sub(startTime)))
320 }
321 }
322}
323
324// httpStatusCodes map the canonical gRPC codes to HTTP status codes
325// as per https://github.com/grpc/grpc/blob/master/doc/statuscodes.md

Callers 1

SearchMethod · 0.85

Calls 2

extractMetaHeaderFunction · 0.85
FocusStatsMethod · 0.80

Tested by

no test coverage detected