index.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import styled from '@emotion/styled';
  2. import Breadcrumbs from 'sentry/components/breadcrumbs';
  3. import FeatureBadge from 'sentry/components/featureBadge';
  4. import * as Layout from 'sentry/components/layouts/thirds';
  5. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  6. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  7. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  8. import {t} from 'sentry/locale';
  9. import {useLocation} from 'sentry/utils/useLocation';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. import {useParams} from 'sentry/utils/useParams';
  12. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  13. import {FilterOptionsContainer} from 'sentry/views/performance/browser/resources/jsCssView';
  14. import ResourceInfo from 'sentry/views/performance/browser/resources/resourceSummaryPage/resourceInfo';
  15. import ResourceSummaryCharts from 'sentry/views/performance/browser/resources/resourceSummaryPage/resourceSummaryCharts';
  16. import ResourceSummaryTable from 'sentry/views/performance/browser/resources/resourceSummaryPage/resourceSummaryTable';
  17. import RenderBlockingSelector from 'sentry/views/performance/browser/resources/shared/renderBlockingSelector';
  18. import {useResourceModuleFilters} from 'sentry/views/performance/browser/resources/utils/useResourceFilters';
  19. import {ModulePageProviders} from 'sentry/views/performance/database/modulePageProviders';
  20. import {useSpanMetrics} from 'sentry/views/starfish/queries/useSpanMetrics';
  21. import {SpanMetricsField} from 'sentry/views/starfish/types';
  22. import {SampleList} from 'sentry/views/starfish/views/spanSummaryPage/sampleList';
  23. const {
  24. SPAN_SELF_TIME,
  25. SPAN_DESCRIPTION,
  26. HTTP_DECODED_RESPONSE_CONTENT_LENGTH,
  27. HTTP_RESPONSE_CONTENT_LENGTH,
  28. HTTP_RESPONSE_TRANSFER_SIZE,
  29. RESOURCE_RENDER_BLOCKING_STATUS,
  30. } = SpanMetricsField;
  31. function ResourceSummary() {
  32. const organization = useOrganization();
  33. const {groupId} = useParams();
  34. const filters = useResourceModuleFilters();
  35. const {
  36. query: {transaction},
  37. } = useLocation();
  38. const {data: spanMetrics} = useSpanMetrics(groupId, {}, [
  39. `avg(${SPAN_SELF_TIME})`,
  40. `avg(${HTTP_RESPONSE_CONTENT_LENGTH})`,
  41. `avg(${HTTP_DECODED_RESPONSE_CONTENT_LENGTH})`,
  42. `avg(${HTTP_RESPONSE_TRANSFER_SIZE})`,
  43. `sum(${SPAN_SELF_TIME})`,
  44. 'spm()',
  45. SPAN_DESCRIPTION,
  46. 'time_spent_percentage()',
  47. ]);
  48. return (
  49. <ModulePageProviders
  50. title={[t('Performance'), t('Resources'), t('Resource Summary')].join(' — ')}
  51. >
  52. <Layout.Header>
  53. <Layout.HeaderContent>
  54. <Breadcrumbs
  55. crumbs={[
  56. {
  57. label: 'Performance',
  58. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  59. preservePageFilters: true,
  60. },
  61. {
  62. label: 'Resources',
  63. to: normalizeUrl(
  64. `/organizations/${organization.slug}/performance/browser/resources/`
  65. ),
  66. preservePageFilters: true,
  67. },
  68. {
  69. label: 'Resource Summary',
  70. },
  71. ]}
  72. />
  73. <Layout.Title>
  74. {spanMetrics[SpanMetricsField.SPAN_DESCRIPTION]}
  75. <FeatureBadge type="alpha" />
  76. </Layout.Title>
  77. </Layout.HeaderContent>
  78. </Layout.Header>
  79. <Layout.Body>
  80. <Layout.Main fullWidth>
  81. <HeaderContainer>
  82. <FilterOptionsContainer>
  83. <PageFilterBar condensed>
  84. <ProjectPageFilter />
  85. <DatePageFilter />
  86. </PageFilterBar>
  87. <RenderBlockingSelector
  88. value={filters[RESOURCE_RENDER_BLOCKING_STATUS] || ''}
  89. />
  90. </FilterOptionsContainer>
  91. <ResourceInfo
  92. avgContentLength={spanMetrics[`avg(${HTTP_RESPONSE_CONTENT_LENGTH})`]}
  93. avgDecodedContentLength={
  94. spanMetrics[`avg(${HTTP_DECODED_RESPONSE_CONTENT_LENGTH})`]
  95. }
  96. avgTransferSize={spanMetrics[`avg(${HTTP_RESPONSE_TRANSFER_SIZE})`]}
  97. avgDuration={spanMetrics[`avg(${SPAN_SELF_TIME})`]}
  98. throughput={spanMetrics['spm()']}
  99. timeSpentTotal={spanMetrics[`sum(${SPAN_SELF_TIME})`]}
  100. timeSpentPercentage={spanMetrics[`time_spent_percentage()`]}
  101. />
  102. </HeaderContainer>
  103. <ResourceSummaryCharts groupId={groupId} />
  104. <ResourceSummaryTable />
  105. <SampleList
  106. transactionRoute="/performance/browser/pageloads/"
  107. groupId={groupId}
  108. transactionName={transaction as string}
  109. additionalFields={[HTTP_RESPONSE_CONTENT_LENGTH]}
  110. />
  111. </Layout.Main>
  112. </Layout.Body>
  113. </ModulePageProviders>
  114. );
  115. }
  116. const HeaderContainer = styled('div')`
  117. display: flex;
  118. justify-content: space-between;
  119. flex-wrap: wrap;
  120. `;
  121. export default ResourceSummary;