Skip to content

Commit 1f44053

Browse files
authored
Merge branch 'develop' into feat/graphql-persisted-operations
2 parents f472764 + f78aa3f commit 1f44053

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

dev-packages/e2e-tests/test-applications/nextjs-pages-dir/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@types/node": "^18.19.1",
2121
"@types/react": "18.0.26",
2222
"@types/react-dom": "18.0.9",
23-
"next": "14.2.32",
23+
"next": "14.2.35",
2424
"react": "18.2.0",
2525
"react-dom": "18.2.0",
2626
"typescript": "~5.0.0"

packages/browser/src/tracing/linkedTraces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ export function addPreviousTraceSpanLink(
176176
if (Date.now() / 1000 - previousTraceInfo.startTimestamp <= PREVIOUS_TRACE_MAX_DURATION) {
177177
if (DEBUG_BUILD) {
178178
debug.log(
179-
`Adding previous_trace ${previousTraceSpanCtx} link to span ${{
179+
`Adding previous_trace \`${JSON.stringify(previousTraceSpanCtx)}\` link to span \`${JSON.stringify({
180180
op: spanJson.op,
181181
...span.spanContext(),
182-
}}`,
182+
})}\``,
183183
);
184184
}
185185

packages/browser/test/tracing/linkedTraces.test.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Span } from '@sentry/core';
2-
import { addChildSpanToSpan, SentrySpan, spanToJSON, timestampInSeconds } from '@sentry/core';
2+
import { addChildSpanToSpan, debug, SentrySpan, spanToJSON, timestampInSeconds } from '@sentry/core';
33
import { beforeEach, describe, expect, it, vi } from 'vitest';
44
import { BrowserClient } from '../../src';
55
import type { PreviousTraceInfo } from '../../src/tracing/linkedTraces';
@@ -201,6 +201,47 @@ describe('addPreviousTraceSpanLink', () => {
201201
});
202202
});
203203

204+
it('logs a debug message when adding a previous trace link (with stringified context)', () => {
205+
const debugLogSpy = vi.spyOn(debug, 'log');
206+
207+
const currentSpanStart = timestampInSeconds();
208+
209+
const previousTraceInfo: PreviousTraceInfo = {
210+
spanContext: { traceId: '123', spanId: '456', traceFlags: 1 },
211+
startTimestamp: currentSpanStart - PREVIOUS_TRACE_MAX_DURATION + 1,
212+
sampleRand: 0.0126,
213+
sampleRate: 0.5,
214+
};
215+
216+
const currentSpan = new SentrySpan({
217+
name: 'test',
218+
op: 'navigation',
219+
startTimestamp: currentSpanStart,
220+
parentSpanId: '789',
221+
spanId: 'abc',
222+
traceId: 'def',
223+
sampled: true,
224+
});
225+
226+
const oldPropagationContext = {
227+
sampleRand: 0.0126,
228+
traceId: '123',
229+
sampled: true,
230+
dsc: { sample_rand: '0.0126', sample_rate: '0.5' },
231+
};
232+
233+
addPreviousTraceSpanLink(previousTraceInfo, currentSpan, oldPropagationContext);
234+
235+
expect(debugLogSpy).not.toHaveBeenCalledWith(expect.stringContaining('[object Object]'));
236+
expect(debugLogSpy).toHaveBeenCalledWith(
237+
expect.stringContaining(
238+
'Adding previous_trace `{"traceId":"123","spanId":"456","traceFlags":1}` link to span `{"op":"navigation","spanId":"abc","traceId":"def","traceFlags":1}`',
239+
),
240+
);
241+
242+
debugLogSpy.mockRestore();
243+
});
244+
204245
it(`doesn't add a previous_trace span link if the previous trace was created more than ${PREVIOUS_TRACE_MAX_DURATION}s ago`, () => {
205246
const currentSpanStart = timestampInSeconds();
206247

0 commit comments

Comments
 (0)