Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/server-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"dependencies": {
"@sentry/core": "10.57.0"
},
"devDependencies": {
"@sentry/conventions": "^0.11.0"
},
"scripts": {
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
Expand Down
1 change: 1 addition & 0 deletions packages/server-utils/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default makeNPMConfigVariants(
exports: 'named',
// set preserveModules to true because we don't want to bundle everything into one file.
preserveModules: true,
preserveModulesRoot: 'src',
},
},
}),
Expand Down
39 changes: 18 additions & 21 deletions packages/server-utils/src/redis/redis-dc-subscriber.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import {
DB_OPERATION_BATCH_SIZE,
DB_QUERY_TEXT,
DB_SYSTEM_NAME,
SERVER_ADDRESS,
SERVER_PORT,
} from '@sentry/conventions/attributes';
import type { Span } from '@sentry/core';
import {
debug,
Expand All @@ -19,16 +26,6 @@ export const IOREDIS_DC_CHANNEL_COMMAND = 'ioredis:command';
export const IOREDIS_DC_CHANNEL_CONNECT = 'ioredis:connect';

const ORIGIN = 'auto.db.redis.diagnostic_channel';

// 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 => {};
Expand Down Expand Up @@ -206,10 +203,10 @@ function setupCommandChannel<T extends RedisCommandData | IORedisCommandData>(
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',
[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 } : {}),
[DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
[DB_QUERY_TEXT]: statement,
...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),
...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),
},
},
span => span,
Expand Down Expand Up @@ -250,12 +247,12 @@ function setupBatchChannel(
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',
[ATTR_DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
[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 } : {}),
...(Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),
...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),
...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),
},
},
span => span,
Expand Down Expand Up @@ -288,9 +285,9 @@ function setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channel
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',
[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 } : {}),
[DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),
...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),
},
},
span => span,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7578,6 +7578,11 @@
"@sentry/cli-win32-i686" "2.58.6"
"@sentry/cli-win32-x64" "2.58.6"

"@sentry/conventions@^0.11.0":
version "0.11.0"
resolved "https://registry.yarnpkg.com/@sentry/conventions/-/conventions-0.11.0.tgz#5a324b8368dc5c141260bd8ccc684756ea3dd843"
integrity sha512-AQTAKeq9mDpOElDFSPymZTPZF/c50rk355mWTf5Y1ZxZJKKOBli5qTttskJyCxrE5ynNgN1KwcXoU5MRrMSRmQ==

"@sentry/node-cpu-profiler@^2.4.2":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@sentry/node-cpu-profiler/-/node-cpu-profiler-2.4.2.tgz#d0ba01370545297d015df1497daf7f81e27f2ab5"
Expand Down
Loading