fix(redis): bring span attributes into alignment with conventions#21255
Conversation
|
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.
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
08abb36 to
0d82ae0
Compare
| [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, |
There was a problem hiding this comment.
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.tsdev-packages/node-integration-tests/suites/tracing/ioredis-dc/test.ts
Did we get this right? 👍 / 👎 to inform future reviews.

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