flamegraphZoomView.stories.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import styled from '@emotion/styled';
  2. import {Flamegraph} from 'sentry/components/profiling/flamegraph/flamegraph';
  3. import {FlamegraphStateProvider} from 'sentry/utils/profiling/flamegraph/flamegraphStateProvider/flamegraphContextProvider';
  4. import {FlamegraphThemeProvider} from 'sentry/utils/profiling/flamegraph/flamegraphThemeProvider';
  5. import {importProfile} from 'sentry/utils/profiling/profile/importProfile';
  6. import {OrganizationContext} from 'sentry/views/organizationContext';
  7. import ProfileGroupProvider from 'sentry/views/profiling/profileGroupProvider';
  8. import {RouteContext} from 'sentry/views/routeContext';
  9. const FlamegraphContainer = styled('div')`
  10. display: flex;
  11. flex-direction: column;
  12. height: 100vh;
  13. `;
  14. export default {
  15. title: 'Components/Profiling/FlamegraphZoomView',
  16. };
  17. const emptyRouteContext = {
  18. location: {
  19. pathname: '',
  20. },
  21. params: {},
  22. };
  23. function FlamegraphStory({profiles}) {
  24. return (
  25. <RouteContext.Provider value={emptyRouteContext}>
  26. <OrganizationContext.Provider value={{}}>
  27. <ProfileGroupProvider>
  28. <FlamegraphStateProvider
  29. initialState={{
  30. profiles: {
  31. threadId: profiles.profiles[0].threadId,
  32. },
  33. }}
  34. >
  35. <FlamegraphThemeProvider>
  36. <FlamegraphContainer>
  37. {profiles && <Flamegraph profiles={profiles} />}
  38. </FlamegraphContainer>
  39. </FlamegraphThemeProvider>
  40. </FlamegraphStateProvider>
  41. </ProfileGroupProvider>
  42. </OrganizationContext.Provider>
  43. </RouteContext.Provider>
  44. );
  45. }
  46. const eventedProfiles = importProfile(
  47. require('sentry/utils/profiling/profile/formats/android/trace.json')
  48. );
  49. export const EventedTrace = () => {
  50. return <FlamegraphStory profiles={eventedProfiles} />;
  51. };
  52. const sampledTrace = importProfile(
  53. require('sentry/utils/profiling/profile/formats/ios/trace.json')
  54. );
  55. export const SampledTrace = () => {
  56. return <FlamegraphStory profiles={sampledTrace} />;
  57. };
  58. const jsSelfProfile = importProfile(
  59. require('sentry/utils/profiling/profile/formats/jsSelfProfile/trace.json')
  60. );
  61. export const JSSelfProfiling = () => {
  62. return <FlamegraphStory profiles={jsSelfProfile} />;
  63. };
  64. const typescriptProfile = importProfile(
  65. require('sentry/utils/profiling/profile/formats/typescript/trace.json')
  66. );
  67. export const TypescriptProfile = () => {
  68. return <FlamegraphStory profiles={typescriptProfile} />;
  69. };