RecordError records client errors (ASK, MOVED, handshake failures, etc.)
( ctx context.Context, errorType string, cn redis.ConnInfo, statusCode string, isInternal bool, retryAttempts int, )
| 581 | |
| 582 | // RecordError records client errors (ASK, MOVED, handshake failures, etc.) |
| 583 | func (r *metricsRecorder) RecordError( |
| 584 | ctx context.Context, |
| 585 | errorType string, |
| 586 | cn redis.ConnInfo, |
| 587 | statusCode string, |
| 588 | isInternal bool, |
| 589 | retryAttempts int, |
| 590 | ) { |
| 591 | if r.clientErrors == nil { |
| 592 | return |
| 593 | } |
| 594 | |
| 595 | // Extract server address and peer address from connection (may be nil for some errors) |
| 596 | // For client connections, peer address is the same as server address (remote endpoint) |
| 597 | var serverAddr, serverPort, peerAddr, peerPort string |
| 598 | if cn != nil { |
| 599 | serverAddr, serverPort = extractServerInfo(cn) |
| 600 | peerAddr, peerPort = serverAddr, serverPort // Peer is same as server for client connections |
| 601 | } |
| 602 | |
| 603 | // Build attributes |
| 604 | attrs := []attribute.KeyValue{ |
| 605 | attribute.String(AttrDBSystemName, DBSystemRedis), |
| 606 | attribute.String(AttrErrorType, errorType), |
| 607 | attribute.String(AttrRedisClientErrorsCategory, getErrorCategoryFromString(errorType)), |
| 608 | attribute.String(AttrDBResponseStatusCode, statusCode), |
| 609 | attribute.Bool(AttrRedisClientErrorsInternal, isInternal), |
| 610 | attribute.Int(AttrRedisClientOperationRetryAttempts, retryAttempts), |
| 611 | getLibraryVersionAttr(), |
| 612 | } |
| 613 | |
| 614 | // Add server info if available |
| 615 | if serverAddr != "" { |
| 616 | attrs = append(attrs, attribute.String(AttrServerAddress, serverAddr)) |
| 617 | attrs = addServerPortIfNonDefault(attrs, serverPort) |
| 618 | } |
| 619 | |
| 620 | // Add peer info if available |
| 621 | if peerAddr != "" { |
| 622 | attrs = append(attrs, attribute.String(AttrNetworkPeerAddress, peerAddr)) |
| 623 | if peerPort != "" { |
| 624 | attrs = append(attrs, attribute.String(AttrNetworkPeerPort, peerPort)) |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | // Record the counter |
| 629 | r.clientErrors.Add(ctx, 1, metric.WithAttributes(attrs...)) |
| 630 | } |
| 631 | |
| 632 | // RecordMaintenanceNotification records when a maintenance notification is received |
| 633 | func (r *metricsRecorder) RecordMaintenanceNotification( |
nothing calls this directly
no test coverage detected