miniAggregateWaterfall.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import styled from '@emotion/styled';
  2. import {LinkButton} from 'sentry/components/button';
  3. import {noFilter} from 'sentry/components/events/interfaces/spans/filter';
  4. import {ActualMinimap} from 'sentry/components/events/interfaces/spans/header';
  5. import {useSpanWaterfallModelFromTransaction} from 'sentry/components/events/interfaces/spans/useSpanWaterfallModelFromTransaction';
  6. import OpsBreakdown from 'sentry/components/events/opsBreakdown';
  7. import LoadingIndicator from 'sentry/components/loadingIndicator';
  8. import {t} from 'sentry/locale';
  9. import {space} from 'sentry/styles/space';
  10. import {useLocation} from 'sentry/utils/useLocation';
  11. import {LandingDisplayField} from 'sentry/views/performance/browser/webVitals/pageOverview';
  12. type Props = {
  13. transaction: string;
  14. };
  15. export function MiniAggregateWaterfall({transaction}: Props) {
  16. const location = useLocation();
  17. // Pageload transactions don't seem to store http.method, so don't include one here
  18. const {waterfallModel, event, isLoading} =
  19. useSpanWaterfallModelFromTransaction(transaction);
  20. if (isLoading) {
  21. return <LoadingIndicator />;
  22. }
  23. const AggregateSpanWaterfallLocation = {
  24. ...location,
  25. query: {
  26. ...location.query,
  27. tab: LandingDisplayField.SPANS,
  28. },
  29. };
  30. const minimap = (
  31. <ActualMinimap
  32. spans={waterfallModel.getWaterfall({
  33. viewStart: 0,
  34. viewEnd: 1,
  35. })}
  36. generateBounds={waterfallModel.generateBounds({
  37. viewStart: 0,
  38. viewEnd: 1,
  39. })}
  40. dividerPosition={0}
  41. rootSpan={waterfallModel.rootSpan.span}
  42. />
  43. );
  44. const opsBreakdown = (
  45. <OpsBreakdown operationNameFilters={noFilter} event={event} topN={3} hideHeader />
  46. );
  47. return (
  48. <span>
  49. <MinimapContainer>{minimap}</MinimapContainer>
  50. <BreakdownContainer>{opsBreakdown}</BreakdownContainer>
  51. <LinkButton
  52. aria-label="View Full Waterfall"
  53. size="sm"
  54. to={AggregateSpanWaterfallLocation}
  55. >
  56. {t('View Full Waterfall')}
  57. </LinkButton>
  58. </span>
  59. );
  60. }
  61. const MinimapContainer = styled('div')`
  62. position: relative;
  63. height: 120px;
  64. `;
  65. // Not ideal, but OpsBreakdown has margins in nested components. Easiest way to update them for now.
  66. const BreakdownContainer = styled('div')`
  67. > div {
  68. margin: 0;
  69. }
  70. margin: ${space(2)} 0;
  71. `;