Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flamegraph): table width #1463

Merged
merged 2 commits into from
Sep 6, 2022
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
107 changes: 82 additions & 25 deletions packages/pyroscope-flamegraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,89 @@ Import the `FlamegraphRenderer` component
import { FlamegraphRenderer, Box } from '@pyroscope/flamegraph';

const SimpleTree = {
topLevel: 0,
rangeMin: 0,
format: 'single' as const,
numTicks: 988,
sampleRate: 100,
names: [
'total',
'runtime.main',
'main.slowFunction',
'main.work',
'main.main',
'main.fastFunction',
],
levels: [
[0, 988, 0, 0],
[0, 988, 0, 1],
[0, 214, 0, 5, 214, 3, 2, 4, 217, 771, 0, 2],
[0, 214, 214, 3, 216, 1, 1, 5, 217, 771, 771, 3],
],

rangeMax: 1,
units: Units.Samples,
fitMode: 'HEAD',

spyName: 'gospy',
version: 1,
flamebearer: {
names: [
'total',
'runtime.mcall',
'runtime.park_m',
'runtime.schedule',
'runtime.resetspinning',
'runtime.wakep',
'runtime.startm',
'runtime.notewakeup',
'runtime.semawakeup',
'runtime.pthread_cond_signal',
'runtime.findrunnable',
'runtime.netpoll',
'runtime.kevent',
'runtime.main',
'main.main',
'github.com/pyroscope-io/client/pyroscope.TagWrapper',
'runtime/pprof.Do',
'github.com/pyroscope-io/client/pyroscope.TagWrapper.func1',
'main.main.func1',
'main.slowFunction',
'main.slowFunction.func1',
'main.work',
'runtime.asyncPreempt',
'main.fastFunction',
'main.fastFunction.func1',
],
levels: [
[0, 609, 0, 0],
[0, 606, 0, 13, 0, 3, 0, 1],
[0, 606, 0, 14, 0, 3, 0, 2],
[0, 606, 0, 15, 0, 3, 0, 3],
[0, 606, 0, 16, 0, 1, 0, 10, 0, 2, 0, 4],
[0, 606, 0, 17, 0, 1, 0, 11, 0, 2, 0, 5],
[0, 606, 0, 18, 0, 1, 1, 12, 0, 2, 0, 6],
[0, 100, 0, 23, 0, 506, 0, 19, 1, 2, 0, 7],
[0, 100, 0, 15, 0, 506, 0, 16, 1, 2, 0, 8],
[0, 100, 0, 16, 0, 506, 0, 20, 1, 2, 2, 9],
[0, 100, 0, 17, 0, 506, 493, 21],
[0, 100, 0, 24, 493, 13, 13, 22],
[0, 100, 97, 21],
[97, 3, 3, 22],
],
numTicks: 609,
maxSelf: 493,
},
metadata: {
appName: 'simple.golang.app.cpu',
name: 'simple.golang.app.cpu 2022-09-06T12:16:31Z',
startTime: 1662466591,
endTime: 1662470191,
query: 'simple.golang.app.cpu{}',
maxNodes: 1024,
format: 'single' as const,
sampleRate: 100,
spyName: 'gospy' as const,
units: 'samples' as const,
},
timeline: {
startTime: 1662466590,
samples: [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 610, 0,
],
durationDelta: 10,
},
};
```

export const Flamegraph = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
font-size: 12px;
visibility: hidden;
z-index: 2;
display: table; /* although this is the default, users may have an overwrite */

&.flamegraphDiffTooltip {
width: 450px;
Expand Down
119 changes: 87 additions & 32 deletions stories/Flamegraph.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,87 @@ export default {
};

const SimpleTree = {
topLevel: 0,
rangeMin: 0,
format: 'single' as const,
numTicks: 988,
sampleRate: 100,
names: [
'total',
'runtime.main',
'main.slowFunction',
'main.work',
'main.main',
'main.fastFunction',
],
levels: [
[0, 988, 0, 0],
[0, 988, 0, 1],
[0, 214, 0, 5, 214, 3, 2, 4, 217, 771, 0, 2],
[0, 214, 214, 3, 216, 1, 1, 5, 217, 771, 771, 3],
],

rangeMax: 1,
units: 'samples',
fitMode: 'HEAD',

spyName: 'gospy',
version: 1,
flamebearer: {
names: [
'total',
'runtime.mcall',
'runtime.park_m',
'runtime.schedule',
'runtime.resetspinning',
'runtime.wakep',
'runtime.startm',
'runtime.notewakeup',
'runtime.semawakeup',
'runtime.pthread_cond_signal',
'runtime.findrunnable',
'runtime.netpoll',
'runtime.kevent',
'runtime.main',
'main.main',
'github.com/pyroscope-io/client/pyroscope.TagWrapper',
'runtime/pprof.Do',
'github.com/pyroscope-io/client/pyroscope.TagWrapper.func1',
'main.main.func1',
'main.slowFunction',
'main.slowFunction.func1',
'main.work',
'runtime.asyncPreempt',
'main.fastFunction',
'main.fastFunction.func1',
],
levels: [
[0, 609, 0, 0],
[0, 606, 0, 13, 0, 3, 0, 1],
[0, 606, 0, 14, 0, 3, 0, 2],
[0, 606, 0, 15, 0, 3, 0, 3],
[0, 606, 0, 16, 0, 1, 0, 10, 0, 2, 0, 4],
[0, 606, 0, 17, 0, 1, 0, 11, 0, 2, 0, 5],
[0, 606, 0, 18, 0, 1, 1, 12, 0, 2, 0, 6],
[0, 100, 0, 23, 0, 506, 0, 19, 1, 2, 0, 7],
[0, 100, 0, 15, 0, 506, 0, 16, 1, 2, 0, 8],
[0, 100, 0, 16, 0, 506, 0, 20, 1, 2, 2, 9],
[0, 100, 0, 17, 0, 506, 493, 21],
[0, 100, 0, 24, 493, 13, 13, 22],
[0, 100, 97, 21],
[97, 3, 3, 22],
],
numTicks: 609,
maxSelf: 493,
},
metadata: {
appName: 'simple.golang.app.cpu',
name: 'simple.golang.app.cpu 2022-09-06T12:16:31Z',
startTime: 1662466591,
endTime: 1662470191,
query: 'simple.golang.app.cpu{}',
maxNodes: 1024,
format: 'single' as const,
sampleRate: 100,
spyName: 'gospy' as const,
units: 'samples' as const,
},
timeline: {
startTime: 1662466590,
samples: [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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},
};

const Template: ComponentStory<typeof Button> = (args) => (
Expand All @@ -45,9 +101,8 @@ const Template: ComponentStory<typeof Button> = (args) => (
}}
>
<FlamegraphRenderer
flamebearer={SimpleTree}
display="flamegraph"
viewType="single"
profile={SimpleTree}
onlyDisplay="flamegraph"
colorMode={args['Light Color Mode'] ? 'light' : 'dark'}
/>
</div>
Expand All @@ -62,23 +117,23 @@ ColorMode.args = {
export const WithToolbar = () => {
return (
<Box>
<FlamegraphRenderer flamebearer={SimpleTree} />
<FlamegraphRenderer profile={SimpleTree} />
</Box>
);
};

export const WithoutToolbar = () => {
return (
<Box>
<FlamegraphRenderer flamebearer={SimpleTree} showToolbar={false} />
<FlamegraphRenderer profile={SimpleTree} showToolbar={false} />
</Box>
);
};

export const JustFlamegraph = () => {
return (
<FlamegraphRenderer
flamebearer={SimpleTree}
profile={SimpleTree}
onlyDisplay="flamegraph"
showToolbar={false}
/>
Expand All @@ -90,7 +145,7 @@ export const TableViewWithoutToolbar = () => {
return (
<Box>
<FlamegraphRenderer
flamebearer={SimpleTree}
profile={SimpleTree}
onlyDisplay="table"
showToolbar={false}
/>
Expand Down