Skip to content

Commit 64a14b6

Browse files
committed
use correct parentchild relationship
1 parent c517e92 commit 64a14b6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/react/src/profiler.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getActiveSpan, startInactiveSpan } from '@sentry/browser';
1+
import { Scope, getActiveSpan, startInactiveSpan } from '@sentry/browser';
22
import type { Span } from '@sentry/types';
33
import { timestampInSeconds } from '@sentry/utils';
44
import hoistNonReactStatics from 'hoist-non-react-statics';
@@ -82,7 +82,10 @@ class Profiler extends React.Component<ProfilerProps> {
8282
const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);
8383
if (changedProps.length > 0 && !this._updateSpan) {
8484
const now = timestampInSeconds();
85+
const scope = new Scope();
86+
scope.setSpan(this._mountSpan);
8587
this._updateSpan = startInactiveSpan({
88+
scope,
8689
name: `<${this.props.name}>`,
8790
op: REACT_UPDATE_OP,
8891
origin: 'auto.ui.react.profiler',
@@ -91,7 +94,6 @@ class Profiler extends React.Component<ProfilerProps> {
9194
changedProps,
9295
'ui.component_name': this.props.name,
9396
},
94-
parentSpanId: this._mountSpan.spanContext().spanId,
9597
});
9698
}
9799
}
@@ -204,13 +206,15 @@ function useProfiler(
204206
return (): void => {
205207
const endTime = timestampInSeconds();
206208
if (mountSpan && options.hasRenderSpan) {
209+
const scope = new Scope();
210+
scope.setSpan(mountSpan);
207211
const renderSpan = startInactiveSpan({
212+
scope,
208213
name: `<${name}>`,
209214
op: REACT_RENDER_OP,
210215
origin: 'auto.ui.react.profiler',
211216
startTimestamp: mountSpan.endTimestamp,
212217
attributes: { 'ui.component_name': name },
213-
parentSpanId: mountSpan.spanContext().spanId,
214218
});
215219
if (renderSpan) {
216220
renderSpan.end(endTime);

0 commit comments

Comments
 (0)