Added OTel instrumentation and metrics export for async client#3977
Merged
vladvildanov merged 29 commits intomasterfrom Mar 3, 2026
Merged
Added OTel instrumentation and metrics export for async client#3977vladvildanov merged 29 commits intomasterfrom
vladvildanov merged 29 commits intomasterfrom
Conversation
* Added async recorder functions * Added exception handling * Added exception handling
* Added export of error metric * Update redis/asyncio/connection.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Codestyle fixes * Added proper retry handling for metric export * Fixed internal flag and retry catching * Removed unnecessary argument --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Added operation duration metric export * Rename metric export methods * Update redis/asyncio/cluster.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update tests/test_asyncio/test_cluster.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Moved metric export, fixed attribute name * Applied comments --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Added connection advanced metrics * Codestyle fixes
* Added pubsub metrics export * Removed imports * Changed assertion
* Added streaming lag metric export * Update redis/commands/core.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Moved imports * Fixed assertions --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
…into feat/async-observability
petyaslavova
approved these changes
Feb 27, 2026
Collaborator
petyaslavova
left a comment
There was a problem hiding this comment.
LGTM.
Just check if the cursor comment is valid, and I think it is ready for merging
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of change
This PR provides recording of metrics for async clients. In terms of public API nothing has been changed so you can use #3954 description or official docs to understand the OTel configuration flow.
We only bring new async recorder functions that is used across async clients to collect the same metrics (where it's possible, CSC and SCH are not available via async clients)
Pull Request check-list
Please make sure to review and check all of these items:
NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Note
Medium Risk
Touches async command execution, retry callbacks, and connection lifecycle paths to emit metrics, which could impact error handling and performance under load. Changes are mostly additive/instrumentation but are in high-traffic code paths (client/cluster/connection/pipeline).
Overview
Adds a new async observability layer (
redis.asyncio.observability.recorder) and wires it into asyncioRedis,PubSub, cluster, pipelines/transactions, connection pools, and connection close/health-check paths to record operation durations, errors/retries, pubsub receive events, streaming lag, connection create/wait/close metrics, and geo failover metrics.Updates async retry to optionally pass a failure count (
with_failure_count) and uses it throughout async code to report retry attempts, while also extending sync streaming commands to export lag metrics for both sync and async (wrapping coroutine responses). Adds an async mode tobenchmarks/otel_benchmark.pyand new/updated asyncio tests validating metric emission and required connection metadata.Written by Cursor Bugbot for commit 0e7d587. This will update automatically on new commits. Configure here.