RecordStreamLag records redis.client.stream.lag metric
( ctx context.Context, lag time.Duration, cn redis.ConnInfo, streamName string, consumerGroup string, consumerName string, )
| 787 | |
| 788 | // RecordStreamLag records redis.client.stream.lag metric |
| 789 | func (r *metricsRecorder) RecordStreamLag( |
| 790 | ctx context.Context, |
| 791 | lag time.Duration, |
| 792 | cn redis.ConnInfo, |
| 793 | streamName string, |
| 794 | consumerGroup string, |
| 795 | consumerName string, |
| 796 | ) { |
| 797 | if r.streamLag == nil { |
| 798 | return |
| 799 | } |
| 800 | |
| 801 | // Extract server address and peer address from connection |
| 802 | serverAddr, serverPort := extractServerInfo(cn) |
| 803 | peerAddr, peerPort := serverAddr, serverPort |
| 804 | |
| 805 | // Build attributes |
| 806 | attrs := []attribute.KeyValue{ |
| 807 | attribute.String(AttrDBSystemName, DBSystemRedis), |
| 808 | attribute.String(AttrServerAddress, serverAddr), |
| 809 | attribute.String(AttrRedisClientStreamConsumerGroup, consumerGroup), |
| 810 | attribute.String(AttrRedisClientStreamConsumerName, consumerName), |
| 811 | getLibraryVersionAttr(), |
| 812 | } |
| 813 | |
| 814 | // Add stream name if not hidden for cardinality reduction |
| 815 | if !r.cfg.hideStreamNames && streamName != "" { |
| 816 | attrs = append(attrs, attribute.String(AttrRedisClientStreamName, streamName)) |
| 817 | } |
| 818 | |
| 819 | // Add server.port if not default |
| 820 | attrs = addServerPortIfNonDefault(attrs, serverPort) |
| 821 | |
| 822 | // Add peer info |
| 823 | if peerAddr != "" { |
| 824 | attrs = append(attrs, attribute.String(AttrNetworkPeerAddress, peerAddr)) |
| 825 | if peerPort != "" { |
| 826 | attrs = append(attrs, attribute.String(AttrNetworkPeerPort, peerPort)) |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | // Record the histogram (lag in seconds) |
| 831 | r.streamLag.Record(ctx, lag.Seconds(), metric.WithAttributes(attrs...)) |
| 832 | } |
| 833 | |
| 834 | // RecordConnectionCount records a change in connection count (UpDownCounter). |
| 835 | // Per OTel semantic conventions, db.client.connection.count is an UpDownCounter. |
nothing calls this directly
no test coverage detected