fix(redis): bring span attributes into alignment with conventions#21255
Conversation
This is phase 1 of the plan to move all server utils into a single reusable package that can be shared across SSJS SDKs. Right now it does not do much, just houses the `diagnostics_channel` redis integrations. In subsequent steps: 1. Code will *not* be moved out of `@sentry/core/server` into `@sentry-internal/server-utils`, in v10. 2. Some or all code in `@sentry/core/server` may be moved into `@sentry-internal/server-utils` in v11, as this would be breaking change. (Redis channel integration was not, because it hasn't yet shipped in a release. Other high-level portable components may move over later, if justified.) 3. No components will ever live in *both* places, because `server-utils` depends on `core`, and that would create a type dependency cycle. `@sentry/core/server` will live on for at least v10, possibly into v11. New server components will be placed in `@sentry-internal/server-utils`. fix: #21222 fix: JS-2631
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
|
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
| ...(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, | ||
| [ATTR_DB_QUERY_TEXT]: statement, |
There was a problem hiding this comment.
Integration tests not updated for renamed attributes
High Severity
The production code now emits db.system.name and db.query.text instead of db.system and db.statement, but the Node.js 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 still assert the old attribute names (e.g. 'db.system': 'redis' and 'db.statement': 'SET dc-test-key ?'). These tests will fail in CI because expect.objectContaining will not match the new keys, causing the integration test suite to break.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 08abb36. Configure here.
size-limit report 📦
|
1e2b91f to
39f2781
Compare


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