Skip to content

Commit

Permalink
feat: implement callgraph report api
Browse files Browse the repository at this point in the history
  • Loading branch information
monicawoj committed Aug 11, 2022
1 parent af20686 commit 83c81c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ui/packages/shared/profile/src/ProfileView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useParcaTheme,
Callgraph as CallgraphComponent,
} from '@parca/components';
import testData from './testdata/link_data.json';
import {useContainerDimensions} from '@parca/dynamicsize';

import ProfileShareButton from './components/ProfileShareButton';
import ProfileIcicleGraph from './ProfileIcicleGraph';
Expand Down Expand Up @@ -88,6 +88,7 @@ export const ProfileView = ({
navigateTo,
profileVisState,
}: ProfileViewProps): JSX.Element => {
const {ref, dimensions} = useContainerDimensions();
const [curPath, setCurPath] = useState<string[]>([]);
const {currentView, setCurrentView} = profileVisState;

Expand Down Expand Up @@ -238,7 +239,7 @@ export const ProfileView = ({
</div>
</div>

<div className="flex space-x-4 justify-between">
<div ref={ref} className="flex space-x-4 justify-between w-full">
{currentView === 'icicle' && flamegraphData?.data != null && (
<div className="w-full">
<ProfileIcicleGraph
Expand All @@ -252,7 +253,11 @@ export const ProfileView = ({

{currentView === 'callgraph' && callgraphData?.data != null && (
<div className="w-full">
<CallgraphComponent graph={testData} sampleUnit={sampleUnit} />
<CallgraphComponent
graph={callgraphData.data}
sampleUnit={sampleUnit}
width={dimensions?.width}
/>
</div>
)}

Expand Down
16 changes: 16 additions & 0 deletions ui/packages/shared/profile/src/ProfileViewWithData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export const ProfileViewWithData = ({
skip: currentView != 'table' && currentView != 'both',
});

const {
isLoading: callgraphLoading,
response: callgraphResponse,
error: callgraphError,
} = useQuery(queryClient, profileSource, QueryRequest_ReportType.CALLGRAPH, {
skip: currentView != 'callgraph',
});

const sampleUnit = profileSource.ProfileType().sampleUnit;

return (
Expand All @@ -54,6 +62,14 @@ export const ProfileViewWithData = ({
topTableResponse?.report.oneofKind === 'top' ? topTableResponse.report.top : undefined,
error: topTableError,
}}
callgraphData={{
loading: callgraphLoading,
data:
callgraphResponse?.report.oneofKind === 'callgraph'
? callgraphResponse?.report?.callgraph
: undefined,
error: callgraphError,
}}
profileVisState={profileVisState}
sampleUnit={sampleUnit}
profileSource={profileSource}
Expand Down

0 comments on commit 83c81c6

Please sign in to comment.