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, )
| 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 |
| 881 | func (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 | } |
nothing calls this directly
no test coverage detected