File tree 2 files changed +13
-1
lines changed
dev-packages/e2e-tests/test-applications/nextjs-app-dir/pages/api
packages/opentelemetry/src 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { get } from 'http' ;
2
+ import { getActiveSpan } from '@sentry/nextjs' ;
2
3
import { NextApiRequest , NextApiResponse } from 'next' ;
3
4
4
5
export default ( _req : NextApiRequest , res : NextApiResponse ) => {
5
6
// make an outgoing request in order to test that the `Http` integration creates a span
7
+ console . log ( 'REQ INSTRUMENTATION TEST' , getActiveSpan ( ) ) ;
6
8
get ( 'http://example.com/' , message => {
7
9
message . on ( 'data' , ( ) => {
8
10
// Noop consuming some data so that request can close :)
9
11
} ) ;
10
12
11
13
message . on ( 'close' , ( ) => {
12
- res . status ( 200 ) . json ( { } ) ;
14
+ setTimeout ( ( ) => {
15
+ res . status ( 200 ) . json ( { } ) ;
16
+ } , 5000 ) ;
17
+ } ) ;
18
+
19
+ message . on ( 'error' , ( ) => {
20
+ setTimeout ( ( ) => {
21
+ res . status ( 200 ) . json ( { } ) ;
22
+ } , 5000 ) ;
13
23
} ) ;
14
24
} ) ;
15
25
} ;
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ export class SentrySpanProcessor implements SpanProcessorInterface {
80
80
* @inheritDoc
81
81
*/
82
82
public onStart ( span : Span , parentContext : Context ) : void {
83
+ console . log ( 'onStart' , span . name , span . attributes ) ;
83
84
onSpanStart ( span , parentContext ) ;
84
85
85
86
// TODO (v8): Trigger client `spanStart` & `spanEnd` in here,
@@ -90,6 +91,7 @@ export class SentrySpanProcessor implements SpanProcessorInterface {
90
91
91
92
/** @inheritDoc */
92
93
public onEnd ( span : ReadableSpan ) : void {
94
+ console . log ( 'onStart' , span . name , span . attributes ) ;
93
95
if ( span . spanContext ( ) . traceFlags !== TraceFlags . SAMPLED ) {
94
96
DEBUG_BUILD && logger . log ( `[Tracing] Finishing unsampled span "${ span . name } " (${ span . spanContext ( ) . spanId } )` ) ;
95
97
return ;
You can’t perform that action at this time.
0 commit comments