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

Method RecordPendingRequests

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

RecordPendingRequests records a change in pending requests (UpDownCounter). Per OTel semantic conventions, db.client.connection.pending_requests is an UpDownCounter. delta: +1 when request starts waiting, -1 when request stops waiting poolName is passed explicitly because we may not have a connectio

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

Source from the content-addressed store, hash-verified

879// delta: +1 when request starts waiting, -1 when request stops waiting
880// poolName is passed explicitly because we may not have a connection yet when request starts
881func (r *metricsRecorder) RecordPendingRequests(
882 ctx context.Context,
883 delta int,
884 cn redis.ConnInfo,
885 poolName string,
886) {
887 if r.connectionPendingReqs == nil {
888 return
889 }
890
891 // Build attributes
892 attrs := []attribute.KeyValue{
893 attribute.String(AttrDBSystemName, DBSystemRedis),
894 getLibraryVersionAttr(),
895 }
896
897 // Use explicit pool name (preferred) or fall back to connection's pool name
898 effectivePoolName := poolName
899 if effectivePoolName == "" && cn != nil {
900 effectivePoolName = cn.PoolName()
901 }
902
903 if effectivePoolName != "" {
904 attrs = append(attrs, attribute.String(AttrDBClientConnectionPoolName, effectivePoolName))
905
906 // Extract server info from pool name
907 serverAddr, serverPort, _ := parsePoolName(effectivePoolName)
908 if serverAddr != "" {
909 attrs = append(attrs, attribute.String(AttrServerAddress, serverAddr))
910 }
911 attrs = addServerPortIfNonDefault(attrs, serverPort)
912 }
913
914 // Record the counter (delta can be +1 or -1)
915 r.connectionPendingReqs.Add(ctx, int64(delta), metric.WithAttributes(attrs...))
916}

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected