From 4b096ed3b235d842e39b540c3611e0303e1c4e53 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 26 Nov 2024 15:56:19 +0100 Subject: [PATCH] fix tests --- .../scenario.ts | 16 +++++++-- .../test.ts | 33 +++++++------------ .../startSpan/parallel-spans-in-scope/test.ts | 4 +-- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/scenario.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/scenario.ts index ec761a7d591d..7c4f702f5df8 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/scenario.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/scenario.ts @@ -15,6 +15,18 @@ Sentry.withScope(scope => { traceId: '12345678901234567890123456789012', }); - Sentry.startSpan({ name: 'test_span_1' }, () => undefined); - Sentry.startSpan({ name: 'test_span_2' }, () => undefined); + const spanIdTraceId = Sentry.startSpan( + { + name: 'test_span_1', + }, + span1 => span1.spanContext().traceId, + ); + + Sentry.startSpan( + { + name: 'test_span_2', + attributes: { spanIdTraceId }, + }, + () => undefined, + ); }); diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/test.ts index 9a561ffd391a..ecc45e46b4a0 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/test.ts @@ -6,28 +6,19 @@ afterAll(() => { test('should send manually started parallel root spans outside of root context with parentSpanId', done => { createRunner(__dirname, 'scenario.ts') + .expect({ transaction: { transaction: 'test_span_1' } }) .expect({ - transaction: { - transaction: 'test_span_1', - contexts: { - trace: { - span_id: expect.any(String), - parent_span_id: '1234567890123456', - trace_id: '12345678901234567890123456789012', - }, - }, - }, - }) - .expect({ - transaction: { - transaction: 'test_span_2', - contexts: { - trace: { - span_id: expect.any(String), - parent_span_id: '1234567890123456', - trace_id: '12345678901234567890123456789012', - }, - }, + transaction: transaction => { + expect(transaction).toBeDefined(); + const traceId = transaction.contexts?.trace?.trace_id; + expect(traceId).toBeDefined(); + expect(transaction.contexts?.trace?.parent_span_id).toBeUndefined(); + + const trace1Id = transaction.contexts?.trace?.data?.spanIdTraceId; + expect(trace1Id).toBeDefined(); + + // Different trace ID as the first span + expect(trace1Id).not.toBe(traceId); }, }) .start(done); diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope/test.ts index 97ceaa1e382c..58cf67c7c69a 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope/test.ts @@ -19,8 +19,8 @@ test('should send manually started parallel root spans outside of root context', const trace1Id = transaction.contexts?.trace?.data?.spanIdTraceId; expect(trace1Id).toBeDefined(); - // Same trace ID as the first span - expect(trace1Id).toBe(traceId); + // Different trace ID as the first span + expect(trace1Id).not.toBe(traceId); }, }) .start(done);