-
-
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
base: isaacs/sentry-internal-server-utils
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, | ||
|
Comment on lines
251
to
261
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Node integration tests for Suggested FixUpdate the assertions in Prompt for AI AgentAlso affects:
Did we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
@@ -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, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.