MCPcopy
hub / github.com/redis/go-redis / RecordConnectionHandoff

Method RecordConnectionHandoff

extra/redisotel-native/metrics.go:556–580  ·  view source on GitHub ↗

RecordConnectionHandoff records when a connection is handed off to another node

(
	ctx context.Context,
	cn redis.ConnInfo,
	poolName string,
)

Source from the content-addressed store, hash-verified

554
555// RecordConnectionHandoff records when a connection is handed off to another node
556func (r *metricsRecorder) RecordConnectionHandoff(
557 ctx context.Context,
558 cn redis.ConnInfo,
559 poolName string,
560) {
561 if r.connectionHandoff == nil {
562 return
563 }
564
565 attrs := []attribute.KeyValue{
566 attribute.String(AttrDBSystemName, DBSystemRedis),
567 getLibraryVersionAttr(),
568 }
569
570 // Use pool name from connection (set when connection was created)
571 if cn != nil {
572 connPoolName := cn.PoolName()
573 if connPoolName != "" {
574 attrs = append(attrs, attribute.String(AttrDBClientConnectionPoolName, connPoolName))
575 }
576 }
577
578 // Record the counter
579 r.connectionHandoff.Add(ctx, 1, metric.WithAttributes(attrs...))
580}
581
582// RecordError records client errors (ASK, MOVED, handshake failures, etc.)
583func (r *metricsRecorder) RecordError(

Callers

nothing calls this directly

Calls 4

getLibraryVersionAttrFunction · 0.85
StringMethod · 0.65
PoolNameMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected