Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(redis): bring span attributes into alignment with conventions#21255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
isaacs
merged 1 commit into
develop
from
isaacs/js-2636-review-redis-diagnostics_channel-span-attribute-namesJun 11, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4 dev-packages/e2e-tests/test-applications/deno-redis/tests/ioredis.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8 dev-packages/e2e-tests/test-applications/deno-redis/tests/redis.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20 dev-packages/node-integration-tests/suites/tracing/ioredis-dc/test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20 dev-packages/node-integration-tests/suites/tracing/redis-dc/test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,13 +20,16 @@ export const IOREDIS_DC_CHANNEL_CONNECT = 'ioredis:connect'; | ||
| const ORIGIN = 'auto.db.redis.diagnostic_channel'; | ||
| // Inlined semconv attribute keys — these are plain strings, no need to depend | ||
| // on @opentelemetry/semantic-conventions for them. | ||
| const ATTR_DB_STATEMENT = 'db.statement'; | ||
| const ATTR_DB_SYSTEM = 'db.system'; | ||
| const ATTR_NET_PEER_NAME = 'net.peer.name'; | ||
| const ATTR_NET_PEER_PORT = 'net.peer.port'; | ||
| const DB_SYSTEM_VALUE_REDIS = 'redis'; | ||
| // Inlined stable semconv attribute keys — these are plain strings, no need to | ||
| // depend on @opentelemetry/semantic-conventions for them. We use the stable | ||
| // OTel names (matching `@sentry/core`'s postgresjs integration) rather than the | ||
| // deprecated `db.statement`/`db.system`/`net.peer.*` forms. | ||
| const ATTR_DB_QUERY_TEXT = 'db.query.text'; | ||
| const ATTR_DB_SYSTEM_NAME = 'db.system.name'; | ||
| const ATTR_DB_OPERATION_BATCH_SIZE = 'db.operation.batch.size'; | ||
| const ATTR_SERVER_ADDRESS = 'server.address'; | ||
| const ATTR_SERVER_PORT = 'server.port'; | ||
| const DB_SYSTEM_NAME_VALUE_REDIS = 'redis'; | ||
| const NOOP = (): void => {}; | ||
| @@ -37,7 +40,7 @@ const NOOP = (): void => {}; | ||
| * `sanitizeArgs` in @redis/client) using the OTel `redis-common` rules. The | ||
| * arg array is `[<command>, <safe arg>, ..., '?', ...]` — `?` replaces any | ||
| * value the library considers sensitive. Subscribers can emit `args` directly | ||
| * as `db.statement` without further serialization. | ||
| * as `db.query.text` without further serialization. | ||
| */ | ||
| export interface RedisCommandData { | ||
| command: string; | ||
| @@ -203,10 +206,10 @@ function setupCommandChannel<T extends RedisCommandData | IORedisCommandData>( | ||
| attributes: { | ||
| [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN, | ||
| [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis', | ||
| [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS, | ||
| [ATTR_DB_STATEMENT]: statement, | ||
| ...(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, | ||
| ...(data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {}), | ||
| ...(data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}), | ||
| }, | ||
| }, | ||
| span => span, | ||
| @@ -247,10 +250,12 @@ function setupBatchChannel( | ||
| attributes: { | ||
| [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, | ||
isaacs marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| @@ -283,9 +288,9 @@ function setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channel | ||
| attributes: { | ||
| [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN, | ||
| [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect', | ||
| [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_REDIS, | ||
| ...(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, | ||
| ...(data.serverAddress != null ? { [ATTR_SERVER_ADDRESS]: data.serverAddress } : {}), | ||
| ...(data.serverPort != null ? { [ATTR_SERVER_PORT]: data.serverPort } : {}), | ||
| }, | ||
| }, | ||
| span => span, | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.