File tree Expand file tree Collapse file tree 6 files changed +77
-25
lines changed
packages/node-integration-tests/suites
public-api/startTransaction
tracing/manual-tracing-namespace-import Expand file tree Collapse file tree 6 files changed +77
-25
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1
- import { assertSentryTransaction , getEnvelopeRequest , runServer } from '../../../utils' ;
1
+ import { assertSentryTransaction , getEnvelopeRequest , runServer } from '../../../../ utils' ;
2
2
3
3
test ( 'should send a manually started transaction when @sentry/tracing is imported using unnamed import.' , async ( ) => {
4
4
const url = await runServer ( __dirname ) ;
Original file line number Diff line number Diff line change
1
+ import '@sentry/tracing' ;
2
+
3
+ import * as Sentry from '@sentry/node' ;
4
+
5
+ Sentry . init ( {
6
+ dsn :
'https://[email protected] /1337' ,
7
+ release : '1.0' ,
8
+ tracesSampleRate : 1.0 ,
9
+ } ) ;
10
+
11
+ const transaction = Sentry . startTransaction ( { name : 'test_transaction_1' } ) ;
12
+ const span_1 = transaction . startChild ( {
13
+ op : 'span_1' ,
14
+ data : {
15
+ foo : 'bar' ,
16
+ baz : [ 1 , 2 , 3 ] ,
17
+ } ,
18
+ } ) ;
19
+ for ( let i = 0 ; i < 2000 ; i ++ ) ;
20
+
21
+ // span_1 finishes
22
+ span_1 . finish ( ) ;
23
+
24
+ // span_2 doesn't finish
25
+ transaction . startChild ( { op : 'span_2' } ) ;
26
+ for ( let i = 0 ; i < 4000 ; i ++ ) ;
27
+
28
+ const span_3 = transaction . startChild ( { op : 'span_3' } ) ;
29
+ for ( let i = 0 ; i < 4000 ; i ++ ) ;
30
+
31
+ // span_4 is the child of span_3 but doesn't finish.
32
+ span_3 . startChild ( { op : 'span_4' , data : { qux : 'quux' } } ) ;
33
+
34
+ // span_5 is another child of span_3 but finishes.
35
+ span_3 . startChild ( { op : 'span_5' } ) . finish ( ) ;
36
+
37
+ // span_3 also finishes
38
+ span_3 . finish ( ) ;
39
+
40
+ transaction . finish ( ) ;
Original file line number Diff line number Diff line change
1
+ import { assertSentryTransaction , getEnvelopeRequest , runServer } from '../../../../utils' ;
2
+
3
+ test ( 'should report finished spans as children of the root transaction.' , async ( ) => {
4
+ const url = await runServer ( __dirname ) ;
5
+ const envelope = await getEnvelopeRequest ( url ) ;
6
+
7
+ expect ( envelope ) . toHaveLength ( 3 ) ;
8
+
9
+ const rootSpanId = ( envelope ?. [ 2 ] as any ) ?. contexts ?. trace ?. span_id ;
10
+ const span3Id = ( envelope ?. [ 2 ] as any ) ?. spans ?. [ 1 ] . span_id ;
11
+
12
+ expect ( rootSpanId ) . toEqual ( expect . any ( String ) ) ;
13
+ expect ( span3Id ) . toEqual ( expect . any ( String ) ) ;
14
+
15
+ assertSentryTransaction ( envelope [ 2 ] , {
16
+ transaction : 'test_transaction_1' ,
17
+ spans : [
18
+ {
19
+ op : 'span_1' ,
20
+ data : {
21
+ foo : 'bar' ,
22
+ baz : [ 1 , 2 , 3 ] ,
23
+ } ,
24
+ parent_span_id : rootSpanId ,
25
+ } ,
26
+ {
27
+ op : 'span_3' ,
28
+ parent_span_id : rootSpanId ,
29
+ } ,
30
+ {
31
+ op : 'span_5' ,
32
+ parent_span_id : span3Id ,
33
+ } ,
34
+ ] ,
35
+ } ) ;
36
+ } ) ;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments