-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathserver.mjs
More file actions
51 lines (44 loc) · 1.5 KB
/
server.mjs
File metadata and controls
51 lines (44 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import express from 'express';
import cors from 'cors';
import * as Sentry from '@sentry/node';
import { startExpressServerAndSendPortToRunner } from '@sentry-internal/node-integration-tests';
const app = express();
app.use(cors());
app.get('/test/express', (_req, res) => {
Sentry.startSpan(
{
name: 'custom-to-drop',
op: 'custom',
},
() => {
Sentry.startSpan(
{
name: 'custom',
op: 'custom',
},
() => {
Sentry.startSpan({ name: 'custom-grandchild', op: 'custom' }, () => {
Sentry.startSpan({ name: 'custom-to-drop-grand-grandchild', op: 'custom' }, () => {
Sentry.startSpan({ name: 'custom-grand-grand-grandchild', op: 'custom' }, () => {});
});
});
Sentry.startSpan({ name: 'custom-grandchild-2', op: 'custom' }, () => {});
},
);
},
);
Sentry.startSpan({ name: 'name-passes-but-op-not-span-1', op: 'ignored-op' }, () => {});
Sentry.startSpan(
// sentry.op attribute has precedence over top op argument
{ name: 'name-passes-but-op-not-span-2', op: 'keep', attributes: { 'sentry.op': 'ignored-op' } },
() => {},
);
res.send({ response: 'response 1' });
setTimeout(() => {
// flush to avoid waiting for the span buffer timeout to send spans
// but defer it to the next tick to let the SDK finish the http.server span first.
Sentry.flush();
});
});
Sentry.setupExpressErrorHandler(app);
startExpressServerAndSendPortToRunner(app);