index.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import styled from '@emotion/styled';
  2. import Breadcrumbs from 'sentry/components/breadcrumbs';
  3. import FeatureBadge from 'sentry/components/featureBadge';
  4. import FileSize from 'sentry/components/fileSize';
  5. import * as Layout from 'sentry/components/layouts/thirds';
  6. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  7. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  8. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  9. import {t} from 'sentry/locale';
  10. import {RateUnits} from 'sentry/utils/discover/fields';
  11. import {useLocation} from 'sentry/utils/useLocation';
  12. import useOrganization from 'sentry/utils/useOrganization';
  13. import {useParams} from 'sentry/utils/useParams';
  14. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  15. import {PaddedContainer} from 'sentry/views/performance/browser/resources';
  16. import ResourceSummaryCharts from 'sentry/views/performance/browser/resources/resourceSummaryPage/resourceSummaryCharts';
  17. import ResourceSummaryTable from 'sentry/views/performance/browser/resources/resourceSummaryPage/resourceSummaryTable';
  18. import {ModulePageProviders} from 'sentry/views/performance/database/modulePageProviders';
  19. import {DurationCell} from 'sentry/views/starfish/components/tableCells/durationCell';
  20. import {ThroughputCell} from 'sentry/views/starfish/components/tableCells/throughputCell';
  21. import {useSpanMetrics} from 'sentry/views/starfish/queries/useSpanMetrics';
  22. import {SpanFunction, SpanMetricsField} from 'sentry/views/starfish/types';
  23. import {DataTitles, getThroughputTitle} from 'sentry/views/starfish/views/spans/types';
  24. import {Block, BlockContainer} from 'sentry/views/starfish/views/spanSummaryPage/block';
  25. import {SampleList} from 'sentry/views/starfish/views/spanSummaryPage/sampleList';
  26. const {
  27. SPAN_SELF_TIME,
  28. SPAN_OP,
  29. SPAN_DESCRIPTION,
  30. HTTP_DECODED_RESPONSE_BODY_LENGTH,
  31. HTTP_RESPONSE_CONTENT_LENGTH,
  32. HTTP_RESPONSE_TRANSFER_SIZE,
  33. } = SpanMetricsField;
  34. function ResourceSummary() {
  35. const organization = useOrganization();
  36. const {groupId} = useParams();
  37. const {
  38. query: {transaction},
  39. } = useLocation();
  40. const {data: spanMetrics} = useSpanMetrics(groupId, {}, [
  41. `avg(${SPAN_SELF_TIME})`,
  42. `avg(${HTTP_RESPONSE_CONTENT_LENGTH})`,
  43. `avg(${HTTP_DECODED_RESPONSE_BODY_LENGTH})`,
  44. `avg(${HTTP_RESPONSE_TRANSFER_SIZE})`,
  45. 'spm()',
  46. SPAN_OP,
  47. SPAN_DESCRIPTION,
  48. ]);
  49. return (
  50. <ModulePageProviders
  51. title={[t('Performance'), t('Resources'), t('Resource Summary')].join(' — ')}
  52. >
  53. <Layout.Header>
  54. <Layout.HeaderContent>
  55. <Breadcrumbs
  56. crumbs={[
  57. {
  58. label: 'Performance',
  59. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  60. preservePageFilters: true,
  61. },
  62. {
  63. label: 'Resources',
  64. to: normalizeUrl(
  65. `/organizations/${organization.slug}/performance/browser/resources/`
  66. ),
  67. preservePageFilters: true,
  68. },
  69. {
  70. label: 'Resource Summary',
  71. },
  72. ]}
  73. />
  74. <Layout.Title>
  75. {spanMetrics[SpanMetricsField.SPAN_DESCRIPTION]}
  76. <FeatureBadge type="alpha" />
  77. </Layout.Title>
  78. </Layout.HeaderContent>
  79. </Layout.Header>
  80. <Layout.Body>
  81. <Layout.Main fullWidth>
  82. <HeaderContainer>
  83. <PaddedContainer>
  84. <PageFilterBar condensed>
  85. <ProjectPageFilter />
  86. <DatePageFilter />
  87. </PageFilterBar>
  88. </PaddedContainer>
  89. <BlockContainer>
  90. <Block title={t('Avg encoded size')}>
  91. <FileSize bytes={spanMetrics?.[`avg(${HTTP_RESPONSE_CONTENT_LENGTH})`]} />
  92. </Block>
  93. <Block title={t('Avg decoded size')}>
  94. <FileSize
  95. bytes={spanMetrics?.[`avg(${HTTP_DECODED_RESPONSE_BODY_LENGTH})`]}
  96. />
  97. </Block>
  98. <Block title={t('Avg transfer size')}>
  99. <FileSize bytes={spanMetrics?.[`avg(${HTTP_RESPONSE_TRANSFER_SIZE})`]} />
  100. </Block>
  101. <Block title={DataTitles.avg}>
  102. <DurationCell
  103. milliseconds={spanMetrics?.[`avg(${SpanMetricsField.SPAN_SELF_TIME})`]}
  104. />
  105. </Block>
  106. <Block title={getThroughputTitle('http')}>
  107. <ThroughputCell
  108. rate={spanMetrics?.[`${SpanFunction.SPM}()`] * 60}
  109. unit={RateUnits.PER_SECOND}
  110. />
  111. </Block>
  112. </BlockContainer>
  113. </HeaderContainer>
  114. <ResourceSummaryCharts groupId={groupId} />
  115. <ResourceSummaryTable />
  116. <SampleList
  117. transactionRoute="/performance/browser/pageloads/"
  118. groupId={groupId}
  119. transactionName={transaction as string}
  120. />
  121. </Layout.Main>
  122. </Layout.Body>
  123. </ModulePageProviders>
  124. );
  125. }
  126. const HeaderContainer = styled('div')`
  127. display: flex;
  128. justify-content: space-between;
  129. flex-wrap: wrap;
  130. `;
  131. export default ResourceSummary;