Skip to content

Commit 9858846

Browse files
author
Luca Forstner
committed
Log for unflaking
1 parent 47f3b1b commit 9858846

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dev-packages/e2e-tests/test-applications/nextjs-app-dir/pages/api/request-instrumentation.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
import { get } from 'http';
2+
import { getActiveSpan, getClient, spanToJSON } from '@sentry/nextjs';
23
import { NextApiRequest, NextApiResponse } from 'next';
34

45
export default (_req: NextApiRequest, res: NextApiResponse) => {
6+
const as = getActiveSpan();
7+
console.log('route active span', as && spanToJSON(as));
58
// make an outgoing request in order to test that the `Http` integration creates a span
69
get('http://example.com/', message => {
710
message.on('data', () => {
811
// Noop consuming some data so that request can close :)
912
});
1013

14+
getClient()?.on('spanEnd', span => {
15+
console.log('onCloseSpan', spanToJSON(span));
16+
if (spanToJSON(span).description === 'GET http://example.com/') {
17+
res.status(200).json({});
18+
}
19+
});
20+
1121
message.on('close', () => {
22+
console.log('close hit');
23+
});
24+
25+
message.on('error', () => {
26+
console.log('error hit');
1227
res.status(200).json({});
1328
});
1429
});

0 commit comments

Comments
 (0)