Skip to content

fix(redis): bring span attributes into alignment with conventions#21255

Open
isaacs wants to merge 1 commit into
isaacs/sentry-internal-server-utilsfrom
isaacs/js-2636-review-redis-diagnostics_channel-span-attribute-names
Open

fix(redis): bring span attributes into alignment with conventions#21255
isaacs wants to merge 1 commit into
isaacs/sentry-internal-server-utilsfrom
isaacs/js-2636-review-redis-diagnostics_channel-span-attribute-names

Conversation

@isaacs
Copy link
Copy Markdown
Member

@isaacs isaacs commented May 30, 2026

Bring the span attributes emitted by the Redis and IORedis diagnostics_channel instrumentations into alignment with OTel and Sentry conventions.

The cache keys are left as-is, because they already align with Sentry's cache conventions, which differ from the DB conventions deliberately.

So:

db.system -> db.system.name
OTel deprecated db.system; Sentry's own span processing (captureSpan.ts) reads db.system.name first; matches postgresjs

db.statement -> db.query.text
OTel deprecated db.statement; matches postgresjs

net.peer.port -> server.port
net.peer.name -> server.address
OTel deprecated net.peer.*; Sentry DB convention uses server.address

db.redis.batch_size -> db.operation.batch.size
OTel's stable batch-size key, proposed addition to sentry conventions: getsentry/sentry-conventions#407

fix: JS-2636
fix: #21227

@isaacs isaacs requested a review from JPeer264 May 30, 2026 01:49
@isaacs isaacs requested a review from a team as a code owner May 30, 2026 01:49
@isaacs isaacs requested review from andreiborza and removed request for a team May 30, 2026 01:49
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 30, 2026

JS-2636

@isaacs
Copy link
Copy Markdown
Member Author

isaacs commented May 30, 2026

Note: the target of this PR is the isaacs/sentry-internal-server-utils branch, because it didn't make much sense to land one of these and immediately conflict the other.

This should land after #21200.

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 08abb36. Configure here.

Comment thread packages/server-utils/src/redis/redis-dc-subscriber.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 30, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.17 kB added added
@sentry/browser - with treeshaking flags 25.62 kB added added
@sentry/browser (incl. Tracing) 45.25 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 47.47 kB added added
@sentry/browser (incl. Tracing, Profiling) 50.22 kB added added
@sentry/browser (incl. Tracing, Replay) 84.83 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.39 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 89.53 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 102.15 kB added added
@sentry/browser (incl. Feedback) 44.34 kB added added
@sentry/browser (incl. sendFeedback) 31.98 kB added added
@sentry/browser (incl. FeedbackAsync) 37.08 kB added added
@sentry/browser (incl. Metrics) 28.25 kB added added
@sentry/browser (incl. Logs) 28.48 kB added added
@sentry/browser (incl. Metrics & Logs) 29.19 kB added added
@sentry/react 28.99 kB added added
@sentry/react (incl. Tracing) 47.51 kB added added
@sentry/vue 32.2 kB added added
@sentry/vue (incl. Tracing) 47.16 kB added added
@sentry/svelte 27.19 kB added added
CDN Bundle 29.55 kB added added
CDN Bundle (incl. Tracing) 47.81 kB added added
CDN Bundle (incl. Logs, Metrics) 31.05 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 49.04 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 70.31 kB added added
CDN Bundle (incl. Tracing, Replay) 85.18 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.35 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 91.05 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.21 kB added added
CDN Bundle - uncompressed 87.59 kB added added
CDN Bundle (incl. Tracing) - uncompressed 144.09 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 92.08 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.85 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 216.81 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.87 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.61 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.57 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280.3 kB added added
@sentry/nextjs (client) 50.03 kB added added
@sentry/sveltekit (client) 45.68 kB added added
@sentry/core/server 75.93 kB added added
@sentry/core/browser 63.09 kB added added
@sentry/node-core 61.69 kB added added
@sentry/node 130.55 kB added added
@sentry/node - without tracing 74.09 kB added added
@sentry/aws-serverless 86.29 kB added added
@sentry/cloudflare (withSentry) - minified 171.64 kB added added
@sentry/cloudflare (withSentry) 429.7 kB added added

@isaacs isaacs force-pushed the isaacs/sentry-internal-server-utils branch from 1e2b91f to 39f2781 Compare May 30, 2026 02:46
Bring the span attributes emitted by the Redis and IORedis
diagnostics_channel instrumentations into alignment with OTel and Sentry
conventions.

The cache keys are left as-is, because they already align with Sentry's
cache conventions, which differ from the DB conventions deliberately.

So:

db.system -> db.system.name
OTel deprecated db.system; Sentry's own span processing (captureSpan.ts)
reads db.system.name first; matches postgresjs

db.statement -> db.query.text
OTel deprecated db.statement; matches postgresjs

net.peer.port -> server.port
net.peer.name -> server.address
OTel deprecated net.peer.*; Sentry DB convention uses server.address

db.redis.batch_size -> db.operation.batch.size
OTel's stable batch-size key, proposed addition to sentry conventions:
getsentry/sentry-conventions#407

fix: JS-2636
fix: #21227
@isaacs isaacs force-pushed the isaacs/js-2636-review-redis-diagnostics_channel-span-attribute-names branch from 08abb36 to 0d82ae0 Compare May 30, 2026 04:45
Comment on lines 251 to 261
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',
[ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS,
...(data.batchSize != null ? { 'db.redis.batch_size': data.batchSize } : {}),
...(data.serverAddress != null ? { [ATTR_NET_PEER_NAME]: data.serverAddress } : {}),
...(data.serverPort != null ? { [ATTR_NET_PEER_PORT]: data.serverPort } : {}),
[ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
// should only include batch size greater than 1,
// or else it isn't properly considered a "batch"
...(Number(data.batchSize) > 1 ? { [ATTR_DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),
...(data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {}),
...(data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}),
},
},
span => span,
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.

Bug: Node integration tests for redis-dc and ioredis-dc assert old attribute names (db.system, db.statement), which will cause test failures against the updated subscriber code.
Severity: HIGH

Suggested Fix

Update the assertions in dev-packages/node-integration-tests/suites/tracing/redis-dc/test.ts and dev-packages/node-integration-tests/suites/tracing/ioredis-dc/test.ts to use the new attribute names, db.system.name and db.query.text, instead of db.system and db.statement.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/server-utils/src/redis/redis-dc-subscriber.ts#L250-L261

Potential issue: The subscriber code in `redis-dc-subscriber.ts` was updated to emit
spans with the new attribute names `db.system.name` and `db.query.text`, replacing
`db.system` and `db.statement`. However, the corresponding node integration tests in
`dev-packages/node-integration-tests/suites/tracing/redis-dc/test.ts` and
`dev-packages/node-integration-tests/suites/tracing/ioredis-dc/test.ts` were not
updated. These tests continue to assert the presence of the old attribute names, which
will cause them to fail when run against the new code, breaking the CI pipeline.

Also affects:

  • dev-packages/node-integration-tests/suites/tracing/redis-dc/test.ts
  • dev-packages/node-integration-tests/suites/tracing/ioredis-dc/test.ts

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant