Skip to content

Commit 4c43129

Browse files
committed
remove unnecessary ignoreSpans check in otel trace.ts files.
1 parent 2974d78 commit 4c43129

File tree

2 files changed

+0
-71
lines changed

2 files changed

+0
-71
lines changed

packages/opentelemetry/src/trace.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import {
2323
hasSpansEnabled,
2424
SDK_VERSION,
2525
SEMANTIC_ATTRIBUTE_SENTRY_OP,
26-
SentryNonRecordingSpan,
27-
shouldIgnoreSpan,
2826
spanToJSON,
2927
spanToTraceContext,
3028
} from '@sentry/core';
@@ -49,16 +47,6 @@ function _startSpan<T>(options: OpenTelemetrySpanContext, callback: (span: Span)
4947
const wrapper = getActiveSpanWrapper<T>(customParentSpan);
5048

5149
return wrapper(() => {
52-
const client = getClient();
53-
const ignoreSpans = client?.getOptions().ignoreSpans;
54-
if (ignoreSpans?.length) {
55-
const op = options.op || options.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP];
56-
if (shouldIgnoreSpan({ description: name, op }, ignoreSpans)) {
57-
client?.recordDroppedEvent('ignored', 'span');
58-
return callback(new SentryNonRecordingSpan());
59-
}
60-
}
61-
6250
const activeCtx = getContext(options.scope, options.forceTransaction);
6351
const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);
6452
const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;
@@ -162,16 +150,6 @@ export function startInactiveSpan(options: OpenTelemetrySpanContext): Span {
162150
const wrapper = getActiveSpanWrapper<Span>(customParentSpan);
163151

164152
return wrapper(() => {
165-
const client = getClient();
166-
const ignoreSpans = client?.getOptions().ignoreSpans;
167-
if (ignoreSpans?.length) {
168-
const op = options.op || options.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_OP];
169-
if (shouldIgnoreSpan({ description: name, op }, ignoreSpans)) {
170-
client?.recordDroppedEvent('ignored', 'span');
171-
return new SentryNonRecordingSpan();
172-
}
173-
}
174-
175153
const activeCtx = getContext(options.scope, options.forceTransaction);
176154
const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);
177155
let ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;

packages/opentelemetry/test/trace.test.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,55 +2190,6 @@ function getSpanName(span: AbstractSpan): string | undefined {
21902190
return spanHasName(span) ? span.name : undefined;
21912191
}
21922192

2193-
describe('trace (ignoreSpans)', () => {
2194-
afterEach(async () => {
2195-
await cleanupOtel();
2196-
});
2197-
2198-
it('returns a non-recording span for an ignored span via startSpan', () => {
2199-
mockSdkInit({ tracesSampleRate: 1, ignoreSpans: ['ignored-span'] });
2200-
2201-
startSpan({ name: 'root' }, () => {
2202-
startSpan({ name: 'ignored-span' }, span => {
2203-
expect(spanIsSampled(span)).toBe(false);
2204-
expect(span.isRecording()).toBe(false);
2205-
});
2206-
});
2207-
});
2208-
2209-
it('children of ignored spans parent to grandparent via startSpan', () => {
2210-
mockSdkInit({ tracesSampleRate: 1, ignoreSpans: ['ignored-span'] });
2211-
2212-
startSpan({ name: 'root' }, rootSpan => {
2213-
const rootSpanId = rootSpan.spanContext().spanId;
2214-
2215-
startSpan({ name: 'ignored-span' }, () => {
2216-
startSpan({ name: 'grandchild' }, grandchildSpan => {
2217-
const parentId = getSpanParentSpanId(grandchildSpan);
2218-
expect(parentId).toBe(rootSpanId);
2219-
});
2220-
});
2221-
});
2222-
});
2223-
2224-
it('returns a non-recording span for an ignored span via startInactiveSpan', () => {
2225-
mockSdkInit({ tracesSampleRate: 1, ignoreSpans: ['ignored-span'] });
2226-
2227-
const span = startInactiveSpan({ name: 'ignored-span' });
2228-
expect(spanIsSampled(span)).toBe(false);
2229-
expect(span.isRecording()).toBe(false);
2230-
});
2231-
2232-
it('does not ignore non-matching spans', () => {
2233-
mockSdkInit({ tracesSampleRate: 1, ignoreSpans: ['ignored-span'] });
2234-
2235-
startSpan({ name: 'normal-span' }, span => {
2236-
expect(spanIsSampled(span)).toBe(true);
2237-
expect(span.isRecording()).toBe(true);
2238-
});
2239-
});
2240-
});
2241-
22422193
function getSpanEndTime(span: AbstractSpan): [number, number] | undefined {
22432194
return (span as ReadableSpan).endTime;
22442195
}

0 commit comments

Comments
 (0)