Skip to content

Commit 4222021

Browse files
committed
more test fixes but they still leak :(
1 parent 97e77e9 commit 4222021

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

packages/opentelemetry/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export { isSentryRequestSpan } from './utils/isSentryRequest';
2525
export { getActiveSpan } from './utils/getActiveSpan';
2626
export { startSpan, startSpanManual, startInactiveSpan, withActiveSpan, continueTrace } from './trace';
2727

28+
export { getDynamicSamplingContextFromSpan } from './utils/dynamicSamplingContext';
29+
2830
// eslint-disable-next-line deprecation/deprecation
2931
export { setupGlobalHub } from './custom/hub';
3032
// eslint-disable-next-line deprecation/deprecation

packages/sveltekit/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@sentry-internal/tracing": "8.0.0-alpha.2",
4141
"@sentry/core": "8.0.0-alpha.2",
4242
"@sentry/node": "8.0.0-alpha.2",
43+
"@sentry/opentelemetry": "8.0.0-alpha.2",
4344
"@sentry/svelte": "8.0.0-alpha.2",
4445
"@sentry/types": "8.0.0-alpha.2",
4546
"@sentry/utils": "8.0.0-alpha.2",
@@ -68,7 +69,7 @@
6869
"fix": "eslint . --format stylish --fix",
6970
"lint": "eslint . --format stylish",
7071
"test": "yarn test:unit",
71-
"test:unit": "vitest run",
72+
"test:unit": "vitest run --outputDiffMaxLines=2000",
7273
"test:watch": "vitest --watch",
7374
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig"
7475
},

packages/sveltekit/src/server/handle.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import {
22
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
33
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
4-
continueTrace,
54
getActiveSpan,
6-
getDynamicSamplingContextFromSpan,
75
getRootSpan,
86
setHttpStatus,
97
spanToTraceHeader,
108
withIsolationScope,
119
} from '@sentry/core';
1210
import { startSpan } from '@sentry/core';
13-
import { captureException } from '@sentry/node';
11+
import { captureException, continueTrace } from '@sentry/node';
1412
import type { Span } from '@sentry/types';
1513
import { dynamicSamplingContextToSentryBaggageHeader, objectify } from '@sentry/utils';
1614
import type { Handle, ResolveOptions } from '@sveltejs/kit';
1715

16+
import { getDynamicSamplingContextFromSpan } from '@sentry/opentelemetry';
17+
1818
import { isHttpError, isRedirect } from '../common/utils';
1919
import { flushIfServerless, getTracePropagationData } from './utils';
2020

packages/sveltekit/src/server/load.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import {
2-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
3-
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
4-
continueTrace,
5-
startSpan,
6-
} from '@sentry/core';
7-
import { captureException } from '@sentry/node';
1+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startSpan } from '@sentry/core';
2+
import { captureException, continueTrace } from '@sentry/node';
83
import { addNonEnumerableProperty, objectify } from '@sentry/utils';
94
import type { LoadEvent, ServerLoadEvent } from '@sveltejs/kit';
105

packages/sveltekit/test/server/load.test.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ describe('wrapServerLoadWithSentry calls trace', () => {
326326
expect(transactions).toHaveLength(1);
327327
const transaction = transactions[0];
328328

329+
console.log(JSON.stringify(transaction.contexts?.trace, null, 2));
330+
329331
expect(transaction.contexts?.trace).toEqual({
330332
data: {
331333
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.sveltekit',
@@ -338,7 +340,6 @@ describe('wrapServerLoadWithSentry calls trace', () => {
338340
op: 'function.sveltekit.server.load',
339341
span_id: expect.any(String),
340342
trace_id: expect.not.stringContaining('1234567890abcdef1234567890abcdef'),
341-
parent_span_id: expect.not.stringContaining('1234567890abcdef'),
342343
origin: 'auto.function.sveltekit',
343344
status: 'ok',
344345
});
@@ -354,7 +355,7 @@ describe('wrapServerLoadWithSentry calls trace', () => {
354355
});
355356
});
356357

357-
it("doesn't attach the DSC data if the baggage header not available", async () => {
358+
it("doesn't attach the DSC data if the baggage header is not available", async () => {
358359
const transactions: Event[] = [];
359360

360361
init({
@@ -381,12 +382,15 @@ describe('wrapServerLoadWithSentry calls trace', () => {
381382
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
382383
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.sveltekit.server.load',
383384
'http.method': 'GET',
385+
'otel.kind': 'INTERNAL',
386+
'sentry.sample_rate': 1,
384387
},
385388
op: 'function.sveltekit.server.load',
386389
parent_span_id: '1234567890abcdef',
387390
span_id: expect.any(String),
388391
trace_id: '1234567890abcdef1234567890abcdef',
389392
origin: 'auto.function.sveltekit',
393+
status: 'ok',
390394
});
391395
expect(transaction.transaction).toEqual('/users/[id]');
392396
expect(transaction.sdkProcessingMetadata?.dynamicSamplingContext).toEqual({});
@@ -422,12 +426,15 @@ describe('wrapServerLoadWithSentry calls trace', () => {
422426
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
423427
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.sveltekit.server.load',
424428
'http.method': 'GET',
429+
'otel.kind': 'INTERNAL',
430+
'sentry.sample_rate': 1,
425431
},
426432
op: 'function.sveltekit.server.load',
427433
parent_span_id: '1234567890abcdef',
428434
span_id: expect.any(String),
429435
trace_id: '1234567890abcdef1234567890abcdef',
430436
origin: 'auto.function.sveltekit',
437+
status: 'ok',
431438
});
432439
expect(transaction.transaction).toEqual('/users/123');
433440
});

0 commit comments

Comments
 (0)