Skip to content

Commit b5c87af

Browse files
committed
ref(core): Add debug log when dropping a span via ignoreSpans
1 parent 2cde2a4 commit b5c87af

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/core/src/utils/should-ignore-span.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
import { DEBUG_BUILD } from '../debug-build';
12
import type { ClientOptions } from '../types-hoist/options';
23
import type { SpanJSON } from '../types-hoist/span';
4+
import { debug } from './debug-logger';
35
import { isMatchingPattern } from './string';
46

7+
function logIgnoredSpan(droppedSpan: Pick<SpanJSON, 'description' | 'op'>): void {
8+
debug.log(`Ignoring span ${droppedSpan.op} - ${droppedSpan.description}`);
9+
}
10+
511
/**
612
* Check if a span should be ignored based on the ignoreSpans configuration.
713
*/
@@ -16,6 +22,7 @@ export function shouldIgnoreSpan(
1622
for (const pattern of ignoreSpans) {
1723
if (isStringOrRegExp(pattern)) {
1824
if (isMatchingPattern(span.description, pattern)) {
25+
DEBUG_BUILD && logIgnoredSpan(span);
1926
return true;
2027
}
2128
continue;
@@ -33,6 +40,7 @@ export function shouldIgnoreSpan(
3340
// not both op and name actually have to match. This is the most efficient way to check
3441
// for all combinations of name and op patterns.
3542
if (nameMatches && opMatches) {
43+
DEBUG_BUILD && logIgnoredSpan(span);
3644
return true;
3745
}
3846
}

packages/core/src/utils/spanUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export function showSpanDropWarning(): void {
323323
consoleSandbox(() => {
324324
// eslint-disable-next-line no-console
325325
console.warn(
326-
'[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly.',
326+
'[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',
327327
);
328328
});
329329
hasShownSpanDropWarning = true;

0 commit comments

Comments
 (0)