1
- import { getActiveSpan , startInactiveSpan } from '@sentry/browser' ;
1
+ import { Scope , getActiveSpan , startInactiveSpan } from '@sentry/browser' ;
2
2
import type { Span } from '@sentry/types' ;
3
3
import { timestampInSeconds } from '@sentry/utils' ;
4
4
import hoistNonReactStatics from 'hoist-non-react-statics' ;
@@ -82,7 +82,10 @@ class Profiler extends React.Component<ProfilerProps> {
82
82
const changedProps = Object . keys ( updateProps ) . filter ( k => updateProps [ k ] !== this . props . updateProps [ k ] ) ;
83
83
if ( changedProps . length > 0 && ! this . _updateSpan ) {
84
84
const now = timestampInSeconds ( ) ;
85
+ const scope = new Scope ( ) ;
86
+ scope . setSpan ( this . _mountSpan ) ;
85
87
this . _updateSpan = startInactiveSpan ( {
88
+ scope,
86
89
name : `<${ this . props . name } >` ,
87
90
op : REACT_UPDATE_OP ,
88
91
origin : 'auto.ui.react.profiler' ,
@@ -91,7 +94,6 @@ class Profiler extends React.Component<ProfilerProps> {
91
94
changedProps,
92
95
'ui.component_name' : this . props . name ,
93
96
} ,
94
- parentSpanId : this . _mountSpan . spanContext ( ) . spanId ,
95
97
} ) ;
96
98
}
97
99
}
@@ -204,13 +206,15 @@ function useProfiler(
204
206
return ( ) : void => {
205
207
const endTime = timestampInSeconds ( ) ;
206
208
if ( mountSpan && options . hasRenderSpan ) {
209
+ const scope = new Scope ( ) ;
210
+ scope . setSpan ( mountSpan ) ;
207
211
const renderSpan = startInactiveSpan ( {
212
+ scope,
208
213
name : `<${ name } >` ,
209
214
op : REACT_RENDER_OP ,
210
215
origin : 'auto.ui.react.profiler' ,
211
216
startTimestamp : mountSpan . endTimestamp ,
212
217
attributes : { 'ui.component_name' : name } ,
213
- parentSpanId : mountSpan . spanContext ( ) . spanId ,
214
218
} ) ;
215
219
if ( renderSpan ) {
216
220
renderSpan . end ( endTime ) ;
0 commit comments