Skip to content

feat(redis): Support streaming spans#6083

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

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

Conversation

@sentrivana
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana commented Apr 16, 2026

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

linear-code Bot commented Apr 16, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

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)
File Patch % Lines
utils.py 16.67% ⚠️ 70 Missing
_async_common.py 0.00% ⚠️ 63 Missing
caches.py 17.46% ⚠️ 52 Missing
_sync_common.py 19.35% ⚠️ 50 Missing
queries.py 21.43% ⚠️ 33 Missing
redis_cluster.py 26.47% ⚠️ 25 Missing

Generated by Codecov Action

Comment thread sentry_sdk/integrations/redis/_async_common.py
Comment thread sentry_sdk/integrations/redis/_sync_common.py Outdated
Comment thread sentry_sdk/integrations/redis/utils.py Outdated
Comment thread sentry_sdk/integrations/redis/_sync_common.py
Comment thread sentry_sdk/integrations/redis/utils.py Outdated
sentrivana and 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 thread tests/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>
Copy link
Copy Markdown
Contributor

@sentry-warden sentry-warden Bot left a comment

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 thread tests/integrations/redis/asyncio/test_redis_asyncio.py
Comment thread tests/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 owner April 23, 2026 08:03
Comment thread tests/integrations/redis/test_redis.py Outdated
Comment thread sentry_sdk/integrations/redis/utils.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 thread sentry_sdk/integrations/redis/modules/queries.py Outdated
Copy link
Copy Markdown
Contributor

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

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 thread sentry_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 master Apr 23, 2026
166 of 168 checks passed
@sentrivana sentrivana deleted the ivana/port-redis-to-span-first branch April 23, 2026 09:17
Sign up for free to 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