File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
dev-packages/e2e-tests/test-applications/nextjs-app-dir/pages/api
packages/opentelemetry/src Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 11import { get } from 'http' ;
2+ import { getActiveSpan } from '@sentry/nextjs' ;
23import { NextApiRequest , NextApiResponse } from 'next' ;
34
45export default ( _req : NextApiRequest , res : NextApiResponse ) => {
56 // make an outgoing request in order to test that the `Http` integration creates a span
7+ console . log ( 'REQ INSTRUMENTATION TEST' , getActiveSpan ( ) ) ;
68 get ( 'http://example.com/' , message => {
79 message . on ( 'data' , ( ) => {
810 // Noop consuming some data so that request can close :)
911 } ) ;
1012
1113 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 ) ;
1323 } ) ;
1424 } ) ;
1525} ;
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ export class SentrySpanProcessor implements SpanProcessorInterface {
8080 * @inheritDoc
8181 */
8282 public onStart ( span : Span , parentContext : Context ) : void {
83+ console . log ( 'onStart' , span . name , span . attributes ) ;
8384 onSpanStart ( span , parentContext ) ;
8485
8586 // TODO (v8): Trigger client `spanStart` & `spanEnd` in here,
@@ -90,6 +91,7 @@ export class SentrySpanProcessor implements SpanProcessorInterface {
9091
9192 /** @inheritDoc */
9293 public onEnd ( span : ReadableSpan ) : void {
94+ console . log ( 'onStart' , span . name , span . attributes ) ;
9395 if ( span . spanContext ( ) . traceFlags !== TraceFlags . SAMPLED ) {
9496 DEBUG_BUILD && logger . log ( `[Tracing] Finishing unsampled span "${ span . name } " (${ span . spanContext ( ) . spanId } )` ) ;
9597 return ;
You can’t perform that action at this time.
0 commit comments