Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -548,57 +548,57 @@ describe('Integration | Transactions', () => {
expect(finishedSpans.length).toBe(0);
});

it('collects child spans that are finished within 5 minutes their parent span has been sent', async () => {
const timeout = 5 * 60 * 1000;
const now = Date.now();
vi.useFakeTimers();
vi.setSystemTime(now);
it('collects child spans that are finished within 5 minutes their parent span has been sent', async () => {
const timeout = 5 * 60 * 1000;
const now = Date.now();
vi.useFakeTimers();
vi.setSystemTime(now);

const logs: unknown[] = [];
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));
const logs: unknown[] = [];
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));

const transactions: Event[] = [];
const transactions: Event[] = [];

mockSdkInit({
tracesSampleRate: 1,
beforeSendTransaction: event => {
transactions.push(event);
return null;
},
});
mockSdkInit({
tracesSampleRate: 1,
beforeSendTransaction: event => {
transactions.push(event);
return null;
},
});

const provider = getProvider();
const spanProcessor = getSpanProcessor();
const provider = getProvider();
const spanProcessor = getSpanProcessor();

const exporter = spanProcessor ? spanProcessor['_exporter'] : undefined;
const exporter = spanProcessor ? spanProcessor['_exporter'] : undefined;

if (!exporter) {
throw new Error('No exporter found, aborting test...');
}
if (!exporter) {
throw new Error('No exporter found, aborting test...');
}

startSpanManual({ name: 'test name' }, async span => {
const subSpan = startInactiveSpan({ name: 'inner span 1' });
subSpan.end();
startSpanManual({ name: 'test name' }, async span => {
const subSpan = startInactiveSpan({ name: 'inner span 1' });
subSpan.end();

const subSpan2 = startInactiveSpan({ name: 'inner span 2' });
const subSpan2 = startInactiveSpan({ name: 'inner span 2' });

span.end();
span.end();

setTimeout(() => {
subSpan2.end();
}, timeout - 2);
});
setTimeout(() => {
subSpan2.end();
}, timeout - 2);
});

vi.advanceTimersByTime(timeout - 1);
vi.advanceTimersByTime(timeout - 1);

expect(transactions).toHaveLength(2);
expect(transactions[0]?.spans).toHaveLength(1);
expect(transactions).toHaveLength(2);
expect(transactions[0]?.spans).toHaveLength(1);

const finishedSpans: any = exporter['_finishedSpanBuckets'].flatMap(bucket =>
bucket ? Array.from(bucket.spans) : [],
);
expect(finishedSpans.length).toBe(0);
});
const finishedSpans: any = exporter['_finishedSpanBuckets'].flatMap(bucket =>
bucket ? Array.from(bucket.spans) : [],
);
expect(finishedSpans.length).toBe(0);
});

it('discards child spans that are finished after 5 minutes their parent span has been sent', async () => {
const timeout = 5 * 60 * 1000;
Expand Down
5 changes: 4 additions & 1 deletion packages/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"import": "./build/esm/index.client.js",
"require": "./build/cjs/index.client.js"
},
"node": "./build/cjs/index.server.js"
"node": {
"import": "./build/esm/index.server.js",
"require": "./build/cjs/index.server.js"
}
}
},
"publishConfig": {
Expand Down
Loading