Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { loggingTransport } from '@sentry-internal/node-integration-tests';
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: loggingTransport,
beforeSend(event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: loggingTransport,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { loggingTransport } from '@sentry-internal/node-integration-tests';
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: loggingTransport,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
transport: loggingTransport,
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { afterAll, test } from 'vitest';
import { afterAll, expect, test } from 'vitest';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

afterAll(() => {
Expand All @@ -25,9 +25,11 @@ test('records a client report and no error event when tracesSampler throws', asy

test('sends the span when tracesSampler throws but tracesSampleRate is 1', async () => {
await createRunner(__dirname, 'scenario-fallback.ts')
.unordered()
.expect({
transaction: {
transaction: 'sampled via tracesSampleRate fallback',
span: container => {
const segment = container.items.find(span => span.is_segment);
expect(segment?.name).toBe('sampled via tracesSampleRate fallback');
},
})
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
sampleRate: 1.0,
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _INTERNAL_MAX_FLAGS_PER_SPAN as MAX_FLAGS_PER_SPAN } from '@sentry/core';
import { _INTERNAL_MAX_FLAGS_PER_SPAN as MAX_FLAGS_PER_SPAN, type SerializedStreamedSpanContainer } from '@sentry/core';
import { afterAll, expect, test } from 'vitest';
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';

Expand All @@ -8,24 +8,31 @@ afterAll(() => {

test('Flags captured on span attributes with max limit', async () => {
// Based on scenario.ts.
const expectedFlags: Record<string, boolean> = {};
const expectedFlags: Record<string, { type: 'boolean'; value: boolean }> = {};
for (let i = 1; i <= MAX_FLAGS_PER_SPAN; i++) {
expectedFlags[`flag.evaluation.feat${i}`] = i === 3;
expectedFlags[`flag.evaluation.feat${i}`] = { type: 'boolean', value: i === 3 };
}
const spans: SerializedStreamedSpanContainer['items'] = [];

await createRunner(__dirname, 'scenario.ts')
.unordered()
.expect({
transaction: {
spans: [
expect.objectContaining({
description: 'test-span',
data: expect.objectContaining({}),
}),
expect.objectContaining({
description: 'test-nested-span',
data: expect.objectContaining(expectedFlags),
}),
],
span: container => {
spans.push(...container.items);
const children = spans.filter(span => !span.is_segment);
expect(children).toHaveLength(2);
expect(children).toEqual(
expect.arrayContaining([
expect.objectContaining({
name: 'test-span',
attributes: expect.objectContaining({}),
}),
expect.objectContaining({
name: 'test-nested-span',
attributes: expect.objectContaining(expectedFlags),
}),
]),
);
},
})
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class GrowthBookWrapper {
const gb = new GrowthBookWrapper();

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
sampleRate: 1.0,
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ afterAll(() => {

test('GrowthBook flags are added to active span attributes on span end', async () => {
await createRunner(__dirname, 'scenario.ts')
.unordered()
.expect({
transaction: {
contexts: {
trace: {
data: {
'flag.evaluation.feat1': true,
'flag.evaluation.feat2': false,
'flag.evaluation.bool-feat': true,
// string-feat should NOT be here since it's not boolean
},
op: 'function',
origin: 'manual',
status: 'ok',
span_id: expect.stringMatching(/[a-f\d]{16}/),
trace_id: expect.stringMatching(/[a-f\d]{32}/),
span: container => {
expect(container.items).toHaveLength(1);
const span = container.items.find(item => item.is_segment);
expect(span).toMatchObject({
name: 'test-span',
status: 'ok',
span_id: expect.stringMatching(/[a-f\d]{16}/),
trace_id: expect.stringMatching(/[a-f\d]{32}/),
attributes: {
'flag.evaluation.feat1': { type: 'boolean', value: true },
'flag.evaluation.feat2': { type: 'boolean', value: false },
'flag.evaluation.bool-feat': { type: 'boolean', value: true },
'sentry.op': { type: 'string', value: 'function' },
'sentry.origin': { type: 'string', value: 'manual' },
},
},
spans: [],
Comment thread
cursor[bot] marked this conversation as resolved.
transaction: 'test-span',
type: 'transaction',
});
// string-feat should NOT be here since it's not boolean
expect(span?.attributes['flag.evaluation.string-feat']).toBeUndefined();
},
})
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const Sentry = require('@sentry/node');
const { expectProcessToExit } = require('../../../utils/expect-process-to-exit');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [
Sentry.onUnhandledRejectionIntegration({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const Sentry = require('@sentry/node');
const { expectProcessToExit } = require('../../../utils/expect-process-to-exit');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
// Use default mode: 'warn' - integration is active but should ignore AI_NoOutputGeneratedError
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const Sentry = require('@sentry/node');
const { expectProcessToExit } = require('../../../utils/expect-process-to-exit');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [Sentry.onUnhandledRejectionIntegration({ mode: 'none' })],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const Sentry = require('@sentry/node');
const { expectProcessToExit } = require('../../../utils/expect-process-to-exit');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [Sentry.onUnhandledRejectionIntegration({ mode: 'strict' })],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const Sentry = require('@sentry/node');
const { expectProcessToExit } = require('../../../utils/expect-process-to-exit');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const Sentry = require('@sentry/node');
const { expectProcessToExit } = require('../../../utils/expect-process-to-exit');

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
transport: loggingTransport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
transport: loggingTransport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'static',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
tracesSampleRate: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Event } from '@sentry/node';
import type { Event, SerializedStreamedSpanContainer } from '@sentry/node';
import * as childProcess from 'child_process';
import * as path from 'path';
import { afterAll, describe, expect, test } from 'vitest';
Expand Down Expand Up @@ -142,15 +142,16 @@ test rejection`);
.completed();
});

// Bun: the error event arrives before the transaction, or has a different span id.
test.skipIf(RUNTIME === 'bun')('handles unhandled rejection in spans', async () => {
let transactionEvent: Event | undefined;
test('handles unhandled rejection in spans', async () => {
let segment: SerializedStreamedSpanContainer['items'][number] | undefined;
let errorEvent: Event | undefined;

await createRunner(__dirname, 'scenario-with-span.ts')
.unordered()
.expect({
transaction: transaction => {
transactionEvent = transaction;
span: container => {
segment = container.items.find(span => span.is_segment);
expect(segment?.name).toBe('test-span');
},
})
.expect({
Expand All @@ -161,23 +162,24 @@ test rejection`);
.start()
.completed();

expect(transactionEvent).toBeDefined();
expect(segment).toBeDefined();
expect(errorEvent).toBeDefined();

expect(transactionEvent!.transaction).toBe('test-span');

expect(transactionEvent!.contexts!.trace!.trace_id).toBe(errorEvent!.contexts!.trace!.trace_id);
expect(transactionEvent!.contexts!.trace!.span_id).toBe(errorEvent!.contexts!.trace!.span_id);
expect(segment!.trace_id).toBe(errorEvent!.contexts!.trace!.trace_id);
expect(segment!.span_id).toBe(errorEvent!.contexts!.trace!.span_id);
});

// Bun: the rejection event's span ID differs from the already-ended span's ID.
test.skipIf(RUNTIME === 'bun')('handles unhandled rejection in spans that are ended early', async () => {
let transactionEvent: Event | undefined;
let segment: SerializedStreamedSpanContainer['items'][number] | undefined;
let errorEvent: Event | undefined;

await createRunner(__dirname, 'scenario-with-span-ended.ts')
.unordered()
.expect({
transaction: transaction => {
transactionEvent = transaction;
span: container => {
segment = container.items.find(span => span.is_segment);
expect(segment?.name).toBe('test-span');
},
})
.expect({
Expand All @@ -188,13 +190,11 @@ test rejection`);
.start()
.completed();

expect(transactionEvent).toBeDefined();
expect(segment).toBeDefined();
expect(errorEvent).toBeDefined();

expect(transactionEvent!.transaction).toBe('test-span');

expect(transactionEvent!.contexts!.trace!.trace_id).toBe(errorEvent!.contexts!.trace!.trace_id);
expect(transactionEvent!.contexts!.trace!.span_id).toBe(errorEvent!.contexts!.trace!.span_id);
expect(segment!.trace_id).toBe(errorEvent!.contexts!.trace!.trace_id);
expect(segment!.span_id).toBe(errorEvent!.contexts!.trace!.span_id);
});

test('should not warn when AI_NoOutputGeneratedError or AbortError is rejected (default ignore)', () =>
Expand Down
Loading