Skip to content

Commit f3f6602

Browse files
committed
ref: Omit redundant captureError: false from tracing-channel callsites
1 parent c34a414 commit f3f6602

3 files changed

Lines changed: 56 additions & 83 deletions

File tree

packages/nestjs/src/integrations/orchestrion-subscriber.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,17 @@ export function subscribeToNestChannels(): void {
128128
// `start`, makes it the active context for the bootstrap, and ends it
129129
// on `asyncEnd` (or `end` if `create` throws synchronously).
130130
//
131-
// `captureError: false`: a failed bootstrap surfaces to the caller.
132-
// We just annotate the span.
133-
//
134131
// `bindTracingChannelToSpan` uses `bindStore`, which needs the
135132
// async-context binding registered after integration `setupOnce`; defer
136133
// until it's available. Only this bind is deferred (it fires at
137134
// `NestFactory.create`, so a retry tick is fine); the plain `.subscribe`
138135
// calls below stay synchronous because the decorator channels fire at
139136
// module-load time, which a deferred subscription could miss.
140137
waitForTracingChannelBinding(() => {
141-
bindTracingChannelToSpan(
142-
diagnosticsChannel.tracingChannel<ChannelContext>(CHANNELS.NESTJS_APP_CREATION),
143-
data => {
144-
const moduleCls = data.arguments?.[0] as { name?: string } | undefined;
145-
return startInactiveSpan(getAppCreationSpanOptions(data.moduleVersion, moduleCls?.name));
146-
},
147-
{ captureError: false },
148-
);
138+
bindTracingChannelToSpan(diagnosticsChannel.tracingChannel<ChannelContext>(CHANNELS.NESTJS_APP_CREATION), data => {
139+
const moduleCls = data.arguments?.[0] as { name?: string } | undefined;
140+
return startInactiveSpan(getAppCreationSpanOptions(data.moduleVersion, moduleCls?.name));
141+
});
149142
});
150143

151144
// request_context + request_handler. `RouterExecutionContext.create`

packages/server-utils/src/integrations/tracing-channel/redis.ts

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ function bindNodeRedisCommandChannel(
232232
return startCommandSpan(commandName, wireArgs.slice(1), nodeRedisAttributes(options));
233233
},
234234
{
235-
captureError: false,
236235
beforeSpanEnd(span, data) {
237236
if ('error' in data || !responseHook) {
238237
return;
@@ -269,46 +268,38 @@ function getExecutorArgs(data: CommandContext): Array<string | Buffer> | undefin
269268

270269
function bindNodeRedisConnectChannel(): void {
271270
const channel = diagnosticsChannel.tracingChannel<CommandContext, CommandContext>(CHANNELS.NODE_REDIS_CONNECT);
272-
bindTracingChannelToSpan(
273-
channel,
274-
data => {
275-
const options = (data.self as NodeRedisClient | undefined)?.options;
276-
return startInactiveSpan({
277-
name: 'redis-connect',
278-
kind: SPAN_KIND.CLIENT,
279-
attributes: { ...nodeRedisAttributes(options), [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db' },
280-
});
281-
},
282-
{ captureError: false },
283-
);
271+
bindTracingChannelToSpan(channel, data => {
272+
const options = (data.self as NodeRedisClient | undefined)?.options;
273+
return startInactiveSpan({
274+
name: 'redis-connect',
275+
kind: SPAN_KIND.CLIENT,
276+
attributes: { ...nodeRedisAttributes(options), [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db' },
277+
});
278+
});
284279
}
285280

286281
// Batch (multi/pipeline): one span per `exec`. Batched commands bypass `sendCommand`, so
287282
// the executor's `ctx.arguments[0]` (the queued commands) gives the batch size. Span shape
288283
// mirrors the native `node-redis:batch` span (see `redis-dc-subscriber.ts`).
289284
function bindNodeRedisBatchChannel(channelName: string, getOperation: (data: CommandContext) => string): void {
290285
const channel = diagnosticsChannel.tracingChannel<CommandContext, CommandContext>(channelName);
291-
bindTracingChannelToSpan(
292-
channel,
293-
data => {
294-
const commands = data.arguments?.[0];
295-
const size = Array.isArray(commands) ? commands.length : undefined;
296-
const socket = (data.self as NodeRedisClient | undefined)?.options?.socket;
297-
return startInactiveSpan({
298-
name: getOperation(data),
299-
kind: SPAN_KIND.CLIENT,
300-
attributes: {
301-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
302-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',
303-
[DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_REDIS,
304-
...(size && size > 1 ? { [DB_OPERATION_BATCH_SIZE]: size } : {}),
305-
...(socket?.host != null ? { [SERVER_ADDRESS]: socket.host } : {}),
306-
...(socket?.port != null ? { [SERVER_PORT]: socket.port } : {}),
307-
},
308-
});
309-
},
310-
{ captureError: false },
311-
);
286+
bindTracingChannelToSpan(channel, data => {
287+
const commands = data.arguments?.[0];
288+
const size = Array.isArray(commands) ? commands.length : undefined;
289+
const socket = (data.self as NodeRedisClient | undefined)?.options?.socket;
290+
return startInactiveSpan({
291+
name: getOperation(data),
292+
kind: SPAN_KIND.CLIENT,
293+
attributes: {
294+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
295+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',
296+
[DB_SYSTEM_NAME]: DB_SYSTEM_VALUE_REDIS,
297+
...(size && size > 1 ? { [DB_OPERATION_BATCH_SIZE]: size } : {}),
298+
...(socket?.host != null ? { [SERVER_ADDRESS]: socket.host } : {}),
299+
...(socket?.port != null ? { [SERVER_PORT]: socket.port } : {}),
300+
},
301+
});
302+
});
312303
}
313304

314305
const _redisChannelIntegration = ((options: RedisChannelIntegrationOptions = {}) => {

packages/server-utils/src/redis/redis-dc-subscriber.ts

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ function setupCommandChannel<T extends RedisCommandData | IORedisCommandData>(
164164
});
165165
},
166166
{
167-
// Command failures are surfaced to (and usually handled by) the caller; only annotate the
168-
// span so we don't emit a duplicate error event for every failed command.
169-
captureError: false,
170167
beforeSpanEnd(span, data) {
171168
if ('error' in data) return;
172169
runResponseHook(responseHook, span, data.command, getCommandArgs(data), data.result);
@@ -180,44 +177,36 @@ function setupBatchChannel(
180177
channelName: string,
181178
getOperationName: (data: RedisBatchData) => string,
182179
): void {
183-
bindTracingChannelToSpan(
184-
tracingChannel<RedisBatchData>(channelName),
185-
data => {
186-
return startInactiveSpan({
187-
name: getOperationName(data),
188-
attributes: {
189-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
190-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',
191-
[DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
192-
// should only include batch size greater than 1,
193-
// or else it isn't properly considered a "batch"
194-
...(Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),
195-
...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),
196-
...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),
197-
},
198-
});
199-
},
200-
{ captureError: false },
201-
);
180+
bindTracingChannelToSpan(tracingChannel<RedisBatchData>(channelName), data => {
181+
return startInactiveSpan({
182+
name: getOperationName(data),
183+
attributes: {
184+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
185+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis',
186+
[DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
187+
// should only include batch size greater than 1,
188+
// or else it isn't properly considered a "batch"
189+
...(Number(data.batchSize) > 1 ? { [DB_OPERATION_BATCH_SIZE]: data.batchSize } : {}),
190+
...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),
191+
...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),
192+
},
193+
});
194+
});
202195
}
203196

204197
function setupConnectChannel(tracingChannel: RedisTracingChannelFactory, channelName: string): void {
205-
bindTracingChannelToSpan(
206-
tracingChannel<RedisConnectData>(channelName),
207-
data => {
208-
return startInactiveSpan({
209-
name: 'redis-connect',
210-
attributes: {
211-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
212-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',
213-
[DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
214-
...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),
215-
...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),
216-
},
217-
});
218-
},
219-
{ captureError: false },
220-
);
198+
bindTracingChannelToSpan(tracingChannel<RedisConnectData>(channelName), data => {
199+
return startInactiveSpan({
200+
name: 'redis-connect',
201+
attributes: {
202+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
203+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db.redis.connect',
204+
[DB_SYSTEM_NAME]: DB_SYSTEM_NAME_VALUE_REDIS,
205+
...(data.serverAddress != null ? { [SERVER_ADDRESS]: data.serverAddress } : {}),
206+
...(data.serverPort != null ? { [SERVER_PORT]: data.serverPort } : {}),
207+
},
208+
});
209+
});
221210
}
222211

223212
function runResponseHook(

0 commit comments

Comments
 (0)