Skip to content
Merged
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
@@ -0,0 +1,30 @@
import { loggingTransport } from '@sentry-internal/node-integration-tests';
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
});

import { startExpressServerAndSendPortToRunner } from '@sentry-internal/node-integration-tests';
import express from 'express';

const app = express();

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

app.get('/test/isolationScope/:id', (req, res) => {
const id = req.params.id;
Sentry.setTag('isolation-scope', 'tag');
Sentry.setTag(`isolation-scope-${id}`, id);
Sentry.setTag('isolation-scope-transactionName', `${Sentry.getIsolationScope().getScopeData().transactionName}`);

Sentry.captureException(new Error('This is an exception'));

res.send({});
});

Sentry.setupExpressErrorHandler(app);

startExpressServerAndSendPortToRunner(app);
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';

afterAll(() => {
cleanupChildProcesses();
});

test('correctly applies isolation scope even without tracing', done => {
const runner = createRunner(__dirname, 'server.ts')
.ignore('session', 'sessions')
.expect({
event: {
tags: {
global: 'tag',
'isolation-scope': 'tag',
'isolation-scope-1': '1',
// We can't properly test non-existance of fields here, so we cast this to a string to test it here
'isolation-scope-transactionName': 'undefined',
},
// Request is correctly set
request: {
url: expect.stringContaining('/test/isolationScope/1'),
headers: {
'user-agent': expect.stringContaining(''),
},
},
},
})
.expect({
event: {
tags: {
global: 'tag',
'isolation-scope': 'tag',
'isolation-scope-2': '2',
// We can't properly test non-existance of fields here, so we cast this to a string to test it here
'isolation-scope-transactionName': 'undefined',
},
// Request is correctly set
request: {
url: expect.stringContaining('/test/isolationScope/2'),
headers: {
'user-agent': expect.stringContaining(''),
},
},
},
})
.start(done);

runner.makeRequest('get', '/test/isolationScope/1').then(() => runner.makeRequest('get', '/test/isolationScope/2'));
});