Skip to content

feat(redis): Support streaming spans - #6083

Merged
sentrivana merged 27 commits into
masterfrom
ivana/port-redis-to-span-first
Apr 23, 2026
Merged

feat(redis): Support streaming spans#6083
sentrivana merged 27 commits into
masterfrom
ivana/port-redis-to-span-first

Conversation

@sentrivana

@sentrivanasentrivana commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Description

Support span streaming in the Redis integration(s).

  • support creating streamed spans
  • move data and tags to attributes
  • make sure attributes are in semantic conventions
  • add tests

The following tags/extra are purposefully left out in the streaming path as they are non-standard and unused:

  • redis.commands
  • redis.transaction
  • redis.is_cluster

The diff size looks terrifying but it's mostly tests 🙏🏻 The actual code changes are very straightforward.

Issues

Reminders

@linear-code

Copy link
Copy Markdown

@github-actions

github-actionsBot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@github-actions

github-actionsBot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

32 passed | Total: 32 | Pass Rate: 100% | Execution Time: 254ms

All tests are passing successfully.

❌ Patch coverage is 9.76%. Project has 16342 uncovered lines.

Files with missing lines (6)
FilePatch %Lines
utils.py16.67%⚠️ 70 Missing
_async_common.py0.00%⚠️ 63 Missing
caches.py17.46%⚠️ 52 Missing
_sync_common.py19.35%⚠️ 50 Missing
queries.py21.43%⚠️ 33 Missing
redis_cluster.py26.47%⚠️ 25 Missing

Generated by Codecov Action

Comment threadsentry_sdk/integrations/redis/_async_common.py
Comment threadsentry_sdk/integrations/redis/_sync_common.py Outdated
Comment threadsentry_sdk/integrations/redis/utils.py Outdated
Comment threadsentry_sdk/integrations/redis/_sync_common.py
Comment threadsentry_sdk/integrations/redis/utils.py Outdated
sentrivanaand others added 2 commits April 22, 2026 16:49
Parametrize all tracing-related tests in the redis integration with
`span_streaming` [True, False] so they exercise both the streaming and
legacy (static) trace lifecycles.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment threadtests/integrations/redis/test_redis_cache_module_async.py
Older redis-py versions (e.g. 4.6.0) emit an extra COMMAND span during
RedisCluster initialization. Mirror the legacy branch's handling so the
streaming assertion tolerates it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@sentry-wardensentry-wardenBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing exception handling around set_db_data_fn and _set_client_data in async client (sentry_sdk/integrations/redis/_async_common.py:147)

In _sentry_execute_command, the calls to set_db_data_fn(db_span, self) and _set_client_data(db_span, is_cluster, name, *args) are not wrapped in capture_internal_exceptions(). The synchronous counterpart in _sync_common.py wraps these calls (lines 147-149). If these functions raise an exception, it will propagate and could cause the Redis command to fail or leave spans unclosed, affecting user operations.

Identified by Warden find-bugs

Comment threadtests/integrations/redis/asyncio/test_redis_asyncio.py
Comment threadtests/integrations/redis/test_redis.py Outdated
@sentrivana
sentrivana marked this pull request as ready for review April 23, 2026 08:03
@sentrivana
sentrivana requested a review from a team as a code ownerApril 23, 2026 08:03
Comment threadtests/integrations/redis/test_redis.py Outdated
Comment threadsentry_sdk/integrations/redis/utils.py Outdated

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b52f66e. Configure here.

Comment threadsentry_sdk/integrations/redis/modules/queries.py Outdated

@alexander-alderman-webbalexander-alderman-webb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I haven't read every line of test change but the ones I looked at were good.

Comment threadsentry_sdk/integrations/redis/utils.py Outdated
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sentrivana
sentrivana enabled auto-merge (squash) April 23, 2026 08:48
@sentrivana
sentrivana merged commit aa4378f into masterApr 23, 2026
166 of 168 checks passed
@sentrivana
sentrivana deleted the ivana/port-redis-to-span-first branch April 23, 2026 09:17
mgaligniana pushed a commit to mgaligniana/sentry-python that referenced this pull request Aug 9, 2026
Support span streaming in the Redis integration(s).
- [x] support creating streamed spans
- [x] move data and tags to attributes
- [x] make sure attributes are in semantic conventions
- [x] add tests
The following tags/extra are purposefully **left out** in the streaming
path as they are non-standard and unused:
- `redis.commands`
- `redis.transaction`
- `redis.is_cluster`
#### Issues
* Closesgetsentry#6052
* Closes PY-2354
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: sentry-warden[bot] <258096371+sentry-warden[bot]@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate redis to span first

2 participants

@sentrivana@alexander-alderman-webb