destinationSummaryPage.tsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import FeatureBadge from 'sentry/components/badge/featureBadge';
  4. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  5. import ButtonBar from 'sentry/components/buttonBar';
  6. import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
  7. import * as Layout from 'sentry/components/layouts/thirds';
  8. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  9. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  10. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  11. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  12. import {t} from 'sentry/locale';
  13. import {space} from 'sentry/styles/space';
  14. import {DurationUnit} from 'sentry/utils/discover/fields';
  15. import {decodeScalar} from 'sentry/utils/queryString';
  16. import {useLocation} from 'sentry/utils/useLocation';
  17. import useOrganization from 'sentry/utils/useOrganization';
  18. import {useOnboardingProject} from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject';
  19. import {MetricReadout} from 'sentry/views/performance/metricReadout';
  20. import * as ModuleLayout from 'sentry/views/performance/moduleLayout';
  21. import {ModulePageProviders} from 'sentry/views/performance/modulePageProviders';
  22. import Onboarding from 'sentry/views/performance/onboarding';
  23. import {LatencyChart} from 'sentry/views/performance/queues/charts/latencyChart';
  24. import {ThroughputChart} from 'sentry/views/performance/queues/charts/throughputChart';
  25. import {MessageSpanSamplesPanel} from 'sentry/views/performance/queues/destinationSummary/messageSpanSamplesPanel';
  26. import {TransactionsTable} from 'sentry/views/performance/queues/destinationSummary/transactionsTable';
  27. import {useQueuesMetricsQuery} from 'sentry/views/performance/queues/queries/useQueuesMetricsQuery';
  28. import {Referrer} from 'sentry/views/performance/queues/referrers';
  29. import {DESTINATION_TITLE, RELEASE_LEVEL} from 'sentry/views/performance/queues/settings';
  30. import {useModuleBreadcrumbs} from 'sentry/views/performance/utils/useModuleBreadcrumbs';
  31. import {getTimeSpentExplanation} from 'sentry/views/starfish/components/tableCells/timeSpentCell';
  32. function DestinationSummaryPage() {
  33. const organization = useOrganization();
  34. const onboardingProject = useOnboardingProject();
  35. const {query} = useLocation();
  36. const destination = decodeScalar(query.destination);
  37. const {data, isLoading} = useQueuesMetricsQuery({
  38. destination,
  39. referrer: Referrer.QUEUES_SUMMARY,
  40. });
  41. const errorRate = 1 - (data[0]?.['trace_status_rate(ok)'] ?? 0);
  42. const crumbs = useModuleBreadcrumbs('queue');
  43. return (
  44. <Fragment>
  45. <Layout.Header>
  46. <Layout.HeaderContent>
  47. <Breadcrumbs
  48. crumbs={[
  49. ...crumbs,
  50. {
  51. label: DESTINATION_TITLE,
  52. },
  53. ]}
  54. />
  55. <Layout.Title>
  56. {destination}
  57. <FeatureBadge type={RELEASE_LEVEL} />
  58. </Layout.Title>
  59. </Layout.HeaderContent>
  60. <Layout.HeaderActions>
  61. <ButtonBar gap={1}>
  62. <FeedbackWidgetButton />
  63. </ButtonBar>
  64. </Layout.HeaderActions>
  65. </Layout.Header>
  66. <Layout.Body>
  67. <Layout.Main fullWidth>
  68. <ModuleLayout.Layout>
  69. <ModuleLayout.Full>
  70. <HeaderContainer>
  71. <PageFilterBar condensed>
  72. <ProjectPageFilter />
  73. <EnvironmentPageFilter />
  74. <DatePageFilter />
  75. </PageFilterBar>
  76. {!onboardingProject && (
  77. <MetricsRibbon>
  78. <MetricReadout
  79. title={t('Avg Time In Queue')}
  80. value={data[0]?.['avg(messaging.message.receive.latency)']}
  81. unit={DurationUnit.MILLISECOND}
  82. isLoading={isLoading}
  83. />
  84. <MetricReadout
  85. title={t('Avg Processing Time')}
  86. value={data[0]?.['avg_if(span.duration,span.op,queue.process)']}
  87. unit={DurationUnit.MILLISECOND}
  88. isLoading={isLoading}
  89. />
  90. <MetricReadout
  91. title={t('Error Rate')}
  92. value={errorRate}
  93. unit={'percentage'}
  94. isLoading={isLoading}
  95. />
  96. <MetricReadout
  97. title={t('Published')}
  98. value={data[0]?.['count_op(queue.publish)']}
  99. unit={'count'}
  100. isLoading={isLoading}
  101. />
  102. <MetricReadout
  103. title={t('Processed')}
  104. value={data[0]?.['count_op(queue.process)']}
  105. unit={'count'}
  106. isLoading={isLoading}
  107. />
  108. <MetricReadout
  109. title={t('Time Spent')}
  110. value={data[0]?.['sum(span.duration)']}
  111. unit={DurationUnit.MILLISECOND}
  112. tooltip={getTimeSpentExplanation(
  113. data[0]?.['time_spent_percentage(app,span.duration)']
  114. )}
  115. isLoading={isLoading}
  116. />
  117. </MetricsRibbon>
  118. )}
  119. </HeaderContainer>
  120. </ModuleLayout.Full>
  121. {onboardingProject && (
  122. <Onboarding organization={organization} project={onboardingProject} />
  123. )}
  124. {!onboardingProject && (
  125. <Fragment>
  126. <ModuleLayout.Half>
  127. <LatencyChart
  128. destination={destination}
  129. referrer={Referrer.QUEUES_SUMMARY_CHARTS}
  130. />
  131. </ModuleLayout.Half>
  132. <ModuleLayout.Half>
  133. <ThroughputChart
  134. destination={destination}
  135. referrer={Referrer.QUEUES_SUMMARY_CHARTS}
  136. />
  137. </ModuleLayout.Half>
  138. <ModuleLayout.Full>
  139. <Flex>
  140. <TransactionsTable />
  141. </Flex>
  142. </ModuleLayout.Full>
  143. </Fragment>
  144. )}
  145. </ModuleLayout.Layout>
  146. </Layout.Main>
  147. </Layout.Body>
  148. <MessageSpanSamplesPanel />
  149. </Fragment>
  150. );
  151. }
  152. function PageWithProviders() {
  153. return (
  154. <ModulePageProviders
  155. moduleName="queue"
  156. pageTitle={t('Destination Summary')}
  157. features="performance-queues-view"
  158. >
  159. <DestinationSummaryPage />
  160. </ModulePageProviders>
  161. );
  162. }
  163. export default PageWithProviders;
  164. const Flex = styled('div')`
  165. display: flex;
  166. flex-direction: column;
  167. gap: ${space(2)};
  168. `;
  169. const MetricsRibbon = styled('div')`
  170. display: flex;
  171. flex-wrap: wrap;
  172. gap: ${space(4)};
  173. `;
  174. const HeaderContainer = styled('div')`
  175. display: flex;
  176. justify-content: space-between;
  177. `;