RecordConnectionCount records a change in connection count (UpDownCounter). Per OTel semantic conventions, db.client.connection.count is an UpDownCounter. delta: +1 when connection added, -1 when connection removed state: connection state (e.g., "idle", "used") isPubSub: true if this is a PubSub con
( ctx context.Context, delta int, cn redis.ConnInfo, state string, isPubSub bool, )
| 837 | // state: connection state (e.g., "idle", "used") |
| 838 | // isPubSub: true if this is a PubSub connection |
| 839 | func (r *metricsRecorder) RecordConnectionCount( |
| 840 | ctx context.Context, |
| 841 | delta int, |
| 842 | cn redis.ConnInfo, |
| 843 | state string, |
| 844 | isPubSub bool, |
| 845 | ) { |
| 846 | if r.connectionCount == nil { |
| 847 | return |
| 848 | } |
| 849 | |
| 850 | // Build attributes |
| 851 | attrs := []attribute.KeyValue{ |
| 852 | attribute.String(AttrDBSystemName, DBSystemRedis), |
| 853 | getLibraryVersionAttr(), |
| 854 | attribute.String(AttrDBClientConnectionState, state), |
| 855 | attribute.Bool(AttrRedisClientConnectionPubSub, isPubSub), |
| 856 | } |
| 857 | |
| 858 | // Use pool name from connection (set when connection was created) |
| 859 | if cn != nil { |
| 860 | poolName := cn.PoolName() |
| 861 | if poolName != "" { |
| 862 | attrs = append(attrs, attribute.String(AttrDBClientConnectionPoolName, poolName)) |
| 863 | |
| 864 | // Extract server info from pool name |
| 865 | serverAddr, serverPort, _ := parsePoolName(poolName) |
| 866 | if serverAddr != "" { |
| 867 | attrs = append(attrs, attribute.String(AttrServerAddress, serverAddr)) |
| 868 | } |
| 869 | attrs = addServerPortIfNonDefault(attrs, serverPort) |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | // Record the counter (delta can be +1 or -1) |
| 874 | r.connectionCount.Add(ctx, int64(delta), metric.WithAttributes(attrs...)) |
| 875 | } |
| 876 | |
| 877 | // RecordPendingRequests records a change in pending requests (UpDownCounter). |
| 878 | // Per OTel semantic conventions, db.client.connection.pending_requests is an UpDownCounter. |
nothing calls this directly
no test coverage detected