Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/react/src/profiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Profiler extends React.Component<ProfilerProps> {
description: `<${name}>`,
op: REACT_MOUNT_OP,
origin: 'auto.ui.react.profiler',
data: { 'ui.component_name': name },
});
}
}
Expand All @@ -87,6 +88,7 @@ class Profiler extends React.Component<ProfilerProps> {
this._updateSpan = this._mountSpan.startChild({
data: {
changedProps,
'ui.component_name': this.props.name,
},
description: `<${this.props.name}>`,
op: REACT_UPDATE_OP,
Expand Down Expand Up @@ -120,6 +122,7 @@ class Profiler extends React.Component<ProfilerProps> {
op: REACT_RENDER_OP,
origin: 'auto.ui.react.profiler',
startTimestamp: this._mountSpan.endTimestamp,
data: { 'ui.component_name': name },
});
}
}
Expand Down Expand Up @@ -184,6 +187,7 @@ function useProfiler(
description: `<${name}>`,
op: REACT_MOUNT_OP,
origin: 'auto.ui.react.profiler',
data: { 'ui.component_name': name },
});
}

Expand All @@ -203,6 +207,7 @@ function useProfiler(
op: REACT_RENDER_OP,
origin: 'auto.ui.react.profiler',
startTimestamp: mountSpan.endTimestamp,
data: { 'ui.component_name': name },
});
}
};
Expand Down
9 changes: 6 additions & 3 deletions packages/react/test/profiler.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe('withProfiler', () => {
description: `<${UNKNOWN_COMPONENT}>`,
op: REACT_MOUNT_OP,
origin: 'auto.ui.react.profiler',
data: { 'ui.component_name': 'unknown' },
});
});
});
Expand All @@ -99,6 +100,7 @@ describe('withProfiler', () => {
op: REACT_RENDER_OP,
origin: 'auto.ui.react.profiler',
startTimestamp: undefined,
data: { 'ui.component_name': 'unknown' },
});
});

Expand All @@ -114,7 +116,6 @@ describe('withProfiler', () => {
expect(mockStartChild).toHaveBeenCalledTimes(1);
});
});

describe('update span', () => {
it('is created when component is updated', () => {
const ProfiledComponent = withProfiler((props: { num: number }) => <div>{props.num}</div>);
Expand All @@ -126,7 +127,7 @@ describe('withProfiler', () => {
rerender(<ProfiledComponent num={1} />);
expect(mockStartChild).toHaveBeenCalledTimes(2);
expect(mockStartChild).toHaveBeenLastCalledWith({
data: { changedProps: ['num'] },
data: { changedProps: ['num'], 'ui.component_name': 'unknown' },
description: `<${UNKNOWN_COMPONENT}>`,
op: REACT_UPDATE_OP,
origin: 'auto.ui.react.profiler',
Expand All @@ -137,7 +138,7 @@ describe('withProfiler', () => {
rerender(<ProfiledComponent num={2} />);
expect(mockStartChild).toHaveBeenCalledTimes(3);
expect(mockStartChild).toHaveBeenLastCalledWith({
data: { changedProps: ['num'] },
data: { changedProps: ['num'], 'ui.component_name': 'unknown' },
description: `<${UNKNOWN_COMPONENT}>`,
op: REACT_UPDATE_OP,
origin: 'auto.ui.react.profiler',
Expand Down Expand Up @@ -180,6 +181,7 @@ describe('useProfiler()', () => {
description: '<Example>',
op: REACT_MOUNT_OP,
origin: 'auto.ui.react.profiler',
data: { 'ui.component_name': 'Example' },
});
});
});
Expand All @@ -203,6 +205,7 @@ describe('useProfiler()', () => {
description: '<Example>',
op: REACT_RENDER_OP,
origin: 'auto.ui.react.profiler',
data: { 'ui.component_name': 'Example' },
}),
);
});
Expand Down