Skip to content
Draft
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 @@ -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.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { afterAll, describe, expect } from 'vitest';
import { assertSentryTransaction } from '../../../utils/assertions';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';

describe('express ignoreLayersType', () => {
Expand All @@ -11,28 +10,26 @@ describe('express ignoreLayersType', () => {
test('suppresses spans for layer types listed in ignoreLayersType', async () => {
const runner = createRunner()
.expect({
transaction: transaction => {
assertSentryTransaction(transaction, {
transaction: 'GET /test/express',
contexts: {
trace: {
op: 'http.server',
status: 'ok',
},
},
span: container => {
expect(container.items.find(item => item.is_segment)).toMatchObject({
name: 'GET /test/express',
status: 'ok',
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'http.server' },
}),
});
expect(transaction.spans).toContainEqual(
expect(container.items).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
'express.type': 'request_handler',
attributes: expect.objectContaining({
'express.type': { type: 'string', value: 'request_handler' },
}),
}),
);
// The cors() middleware span is suppressed by ignoreLayersType: ['middleware'].
expect(transaction.spans).not.toContainEqual(
expect(container.items).not.toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
'express.type': 'middleware',
attributes: expect.objectContaining({
'express.type': { type: 'string', value: 'middleware' },
}),
}),
);
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.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { afterAll, describe } from 'vitest';
import { afterAll, describe, expect } from 'vitest';
import { cleanupChildProcesses, createCjsTests } from '../../../utils/runner';

describe('express multiple routers', () => {
Expand All @@ -9,7 +9,7 @@ describe('express multiple routers', () => {
createCjsTests(__dirname, 'scenario-common-infix.mjs', 'instrument.mjs', (createRunner, test) => {
test('should construct correct url with common infixes with multiple routers.', async () => {
const runner = createRunner()
.ignore('transaction')
.ignore('span')
.expect({ event: { message: 'Custom Message', transaction: 'GET /api2/v1/test' } })
.start();
runner.makeRequest('get', '/api2/v1/test');
Expand All @@ -20,7 +20,7 @@ describe('express multiple routers', () => {
createCjsTests(__dirname, 'scenario-common-infix-parameterized.mjs', 'instrument.mjs', (createRunner, test) => {
test('should construct correct url with common infixes with multiple parameterized routers.', async () => {
const runner = createRunner()
.ignore('transaction')
.ignore('span')
.expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/user/:userId' } })
.start();
runner.makeRequest('get', '/api/v1/user/3212');
Expand All @@ -31,7 +31,7 @@ describe('express multiple routers', () => {
createCjsTests(__dirname, 'scenario-common-prefix.mjs', 'instrument.mjs', (createRunner, test) => {
test('should construct correct urls with multiple routers.', async () => {
const runner = createRunner()
.ignore('transaction')
.ignore('span')
.expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/test' } })
.start();
runner.makeRequest('get', '/api/v1/test');
Expand All @@ -40,7 +40,7 @@ describe('express multiple routers', () => {

test('should construct correct urls with multiple parameterized routers.', async () => {
const runner = createRunner()
.ignore('transaction')
.ignore('span')
.expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/user/:userId' } })
.start();
runner.makeRequest('get', '/api/v1/user/1234/');
Expand All @@ -51,7 +51,7 @@ describe('express multiple routers', () => {
createCjsTests(__dirname, 'scenario-common-prefix-reverse.mjs', 'instrument.mjs', (createRunner, test) => {
test('should construct correct urls with multiple parameterized routers (use order reversed).', async () => {
const runner = createRunner()
.ignore('transaction')
.ignore('span')
.expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/user/:userId' } })
.start();
runner.makeRequest('get', '/api/v1/user/1234/');
Expand All @@ -62,7 +62,7 @@ describe('express multiple routers', () => {
createCjsTests(__dirname, 'scenario-common-prefix-same-length.mjs', 'instrument.mjs', (createRunner, test) => {
test('should construct correct url with multiple parameterized routers of the same length.', async () => {
const runner = createRunner()
.ignore('transaction')
.ignore('span')
.expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/:userId' } })
.start();
runner.makeRequest('get', '/api/v1/1234/');
Expand All @@ -76,11 +76,10 @@ describe('express multiple routers', () => {
const runner = createRunner()
.ignore('event')
.expect({
transaction: {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
span: container => {
const serverSpan = container.items.find(item => item.is_segment);
expect(serverSpan?.name).toBe('GET /api/api/v1/sub-router/users/:userId/posts/:postId');
expect(serverSpan?.attributes['sentry.segment.name.source']).toEqual({ type: 'string', value: 'route' });
},
})
.start();
Expand All @@ -92,11 +91,10 @@ describe('express multiple routers', () => {
const runner = createRunner()
.ignore('event')
.expect({
transaction: {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
span: container => {
const serverSpan = container.items.find(item => item.is_segment);
expect(serverSpan?.name).toBe('GET /api/api/v1/sub-router/users/:userId/posts/:postId');
expect(serverSpan?.attributes['sentry.segment.name.source']).toEqual({ type: 'string', value: 'route' });
},
})
.start();
Expand All @@ -108,11 +106,10 @@ describe('express multiple routers', () => {
const runner = createRunner()
.ignore('event')
.expect({
transaction: {
transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
span: container => {
const serverSpan = container.items.find(item => item.is_segment);
expect(serverSpan?.name).toBe('GET /api/api/v1/sub-router/users/:userId/posts/:postId');
expect(serverSpan?.attributes['sentry.segment.name.source']).toEqual({ type: 'string', value: 'route' });
},
})
.start();
Expand All @@ -129,11 +126,10 @@ describe('express multiple routers', () => {
const runner = createRunner()
.ignore('event')
.expect({
transaction: {
transaction: 'GET /api/v1/users/:userId/posts/:postId',
transaction_info: {
source: 'route',
},
span: container => {
const serverSpan = container.items.find(item => item.is_segment);
expect(serverSpan?.name).toBe('GET /api/v1/users/:userId/posts/:postId');
expect(serverSpan?.attributes['sentry.segment.name.source']).toEqual({ type: 'string', value: 'route' });
},
})
.start();
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.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import express from 'express';

const app = express();

Sentry.setTag('global', 'tag');
Sentry.setAttribute('global', 'attribute');

app.get('/test/isolationScope', (_req, res) => {
// eslint-disable-next-line no-console
console.log('This is a test log.');
Sentry.addBreadcrumb({ message: 'manual breadcrumb' });
Sentry.setTag('isolation-scope', 'tag');
Sentry.setAttribute('isolation-scope', 'attribute');
Sentry.setUser({ id: 'user-1' });

res.send({});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,17 @@ describe('express span isolationScope', () => {
test('correctly applies isolation scope to span', async () => {
const runner = createRunner()
.expect({
transaction: {
transaction: 'GET /test/isolationScope',
breadcrumbs: [
{
category: 'console',
level: 'log',
message: expect.stringMatching(/\{"port":(\d+)\}/),
timestamp: expect.any(Number),
},
{
category: 'console',
level: 'log',
message: 'This is a test log.',
timestamp: expect.any(Number),
},
{
message: 'manual breadcrumb',
timestamp: expect.any(Number),
},
],
tags: {
global: 'tag',
'isolation-scope': 'tag',
},
span: container => {
const serverSpan = container.items.find(item => item.is_segment);

expect(serverSpan).toMatchObject({
name: 'GET /test/isolationScope',
attributes: expect.objectContaining({
global: { type: 'string', value: 'attribute' },
'isolation-scope': { type: 'string', value: 'attribute' },
'user.id': { type: 'string', value: 'user-1' },
}),
});
},
})
.start();
Expand Down

This file was deleted.

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

Sentry.init({
traceLifecycle: process.env.STREAMED === 'true' ? 'stream' : 'static',
traceLifecycle: 'stream',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
// disable attaching headers to /test/* endpoints
Expand Down

This file was deleted.

Loading
Loading