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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';

import {FlamegraphViewSelectMenu} from 'sentry/components/profiling/FlamegraphViewSelectMenu';
import {FlamegraphZoomView} from 'sentry/components/profiling/FlamegraphZoomView';
import {FlamegraphZoomViewMinimap} from 'sentry/components/profiling/FlamegraphZoomViewMinimap';
import {CanvasPoolManager} from 'sentry/utils/profiling/canvasScheduler';
Expand All @@ -16,8 +17,16 @@ export default {
export const EventedTrace = () => {
const canvasPoolManager = new CanvasPoolManager();

const [view, setView] = React.useState({inverted: false, leftHeavy: false});

const profiles = importProfile(trace);
const flamegraph = new Flamegraph(profiles.profiles[0]);

const flamegraph = new Flamegraph(
profiles.profiles[0],
0,
view.inverted,
view.leftHeavy
);

return (
<div
Expand All @@ -29,6 +38,18 @@ export const EventedTrace = () => {
overscrollBehavior: 'contain',
}}
>
<div>
<FlamegraphViewSelectMenu
view={view.inverted ? 'bottom up' : 'top down'}
sorting={view.leftHeavy ? 'left heavy' : 'call order'}
onSortingChange={s => {
setView({...view, leftHeavy: s === 'left heavy'});
}}
onViewChange={v => {
setView({...view, inverted: v === 'bottom up'});
}}
/>
</div>
<div style={{height: 100, position: 'relative'}}>
<FlamegraphZoomViewMinimap
flamegraph={flamegraph}
Expand Down
52 changes: 52 additions & 0 deletions static/app/components/profiling/FlamegraphViewSelectMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Button from 'sentry/components/button';
import ButtonBar from 'sentry/components/buttonBar';
import {t} from 'sentry/locale';

interface FlamegraphViewSelectMenuProps {
onSortingChange: (sorting: FlamegraphViewSelectMenuProps['sorting']) => void;
onViewChange: (view: FlamegraphViewSelectMenuProps['view']) => void;
sorting: 'call order' | 'left heavy';
view: 'top down' | 'bottom up';
}

function FlamegraphViewSelectMenu({
view,
onViewChange,
sorting,
onSortingChange,
}: FlamegraphViewSelectMenuProps): React.ReactElement {
return (
<ButtonBar merged>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the gif outdated? Doesn't look like it's using the button bar

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed, it's outdated!

<Button
size="xsmall"
priority={sorting === 'call order' ? 'primary' : undefined}
onClick={() => onSortingChange('call order')}
>
{t('Call Order')}
</Button>
<Button
size="xsmall"
priority={sorting === 'left heavy' ? 'primary' : undefined}
onClick={() => onSortingChange('left heavy')}
>
{t('Left Heavy')}
</Button>
<Button
size="xsmall"
priority={view === 'bottom up' ? 'primary' : undefined}
onClick={() => onViewChange('bottom up')}
>
{t('Bottom Up')}
</Button>
<Button
size="xsmall"
priority={view === 'top down' ? 'primary' : undefined}
onClick={() => onViewChange('top down')}
>
{t('Top Down')}
</Button>
</ButtonBar>
);
}

export {FlamegraphViewSelectMenu};
4 changes: 2 additions & 2 deletions tests/js/spec/utils/profiling/renderers/gridRenderer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('getIntervalTimeAtX', () => {
physicalSpace
);

expect(getIntervalTimeAtX(configToPhysical, 500)).toBe(15);
expect(getIntervalTimeAtX(configToPhysical, 500)).toBe(10);
});

it('high dpr - when origin is at 0', () => {
Expand All @@ -57,7 +57,7 @@ describe('getIntervalTimeAtX', () => {
physicalSpace
);

expect(getIntervalTimeAtX(configToPhysical, 500)).toBe(20);
expect(getIntervalTimeAtX(configToPhysical, 500)).toBe(15);
});
});

Expand Down