Skip to content

Commit 1825c15

Browse files
committed
fix strict mode
1 parent 334eac9 commit 1825c15

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

packages/opentelemetry-node/src/spanprocessor.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ export class SentrySpanProcessor implements OtelSpanProcessor {
8585
// so we cannot use hub.getSpan(), as we cannot rely on this being on the current span
8686
const sentryParentSpan = otelParentSpanId && SENTRY_SPAN_PROCESSOR_MAP.get(otelParentSpanId);
8787

88-
if (this._strictSpanParentHandling && otelParentSpanId && !sentryParentSpan) {
89-
logger.warn(
90-
`SentrySpanProcessor could not find parent span with OTEL-spanId ${otelParentSpanId}. Dropping the span "${otelSpan.name}" with OTEL-spanID ${otelSpanId}...`,
91-
);
92-
return;
93-
}
94-
9588
if (sentryParentSpan) {
9689
const sentryChildSpan = sentryParentSpan.startChild({
9790
description: otelSpan.name,

packages/opentelemetry-node/test/spanprocessor.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,8 @@ describe('SentrySpanProcessor', () => {
937937
});
938938
});
939939

940-
it('aborts when encountering a missing parent reference', () => {
940+
// If we cannot find the parent span, it means we are continuing a trace from somehwere else
941+
it('handles missing parent reference', () => {
941942
const startTimestampMs = 1667381672309;
942943
const endTimestampMs = 1667381672875;
943944
const startTime = otelNumberToHrtime(startTimestampMs);
@@ -947,19 +948,20 @@ describe('SentrySpanProcessor', () => {
947948

948949
tracer.startActiveSpan('GET /users', parentOtelSpan => {
949950
// We simulate the parent somehow not existing in our internal map
950-
// this can happen if a race condition leads to spans being processed out of order
951951
SENTRY_SPAN_PROCESSOR_MAP.delete(parentOtelSpan.spanContext().spanId);
952952

953953
tracer.startActiveSpan('SELECT * FROM users;', { startTime }, child => {
954954
const childOtelSpan = child as OtelSpan;
955955

956-
// Parent span does not exist...
956+
// Parent span cannot be looked up, because we deleted the reference before...
957957
const sentrySpanTransaction = getSpanForOtelSpan(parentOtelSpan);
958958
expect(sentrySpanTransaction).toBeUndefined();
959959

960-
// Span itself does not exist...
960+
// Span itself does does exist as a transaction
961961
const sentrySpan = getSpanForOtelSpan(childOtelSpan);
962-
expect(sentrySpan).toBeUndefined();
962+
expect(sentrySpan).toBeDefined();
963+
expect(sentrySpan).toBeInstanceOf(Transaction);
964+
expect(sentrySpan?.parentSpanId).toEqual(parentOtelSpan.spanContext().spanId);
963965

964966
child.end(endTime);
965967
});
@@ -1004,9 +1006,12 @@ describe('SentrySpanProcessor', () => {
10041006
child.end();
10051007

10061008
expect(parentSpan).toBeDefined();
1007-
expect(childSpan).not.toBeDefined();
1009+
expect(childSpan).toBeDefined();
10081010
expect(parentSpan).toBeInstanceOf(Transaction);
1011+
expect(childSpan).toBeInstanceOf(Transaction);
1012+
expect(childSpan?.parentSpanId).toEqual(parentSpan?.spanId);
10091013
expect(parentSpan?.endTimestamp).toBeDefined();
1014+
expect(childSpan?.endTimestamp).toBeDefined();
10101015
});
10111016
});
10121017
});

0 commit comments

Comments
 (0)