cacheLandingPage.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import React from 'react';
  2. import FeatureBadge from 'sentry/components/badge/featureBadge';
  3. import {Breadcrumbs} from 'sentry/components/breadcrumbs';
  4. import ButtonBar from 'sentry/components/buttonBar';
  5. import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
  6. import * as Layout from 'sentry/components/layouts/thirds';
  7. import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
  8. import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
  9. import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
  10. import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
  11. import {t} from 'sentry/locale';
  12. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  15. import {CacheHitMissChart} from 'sentry/views/performance/cache/charts/hitMissChart';
  16. import {ThroughputChart} from 'sentry/views/performance/cache/charts/throughputChart';
  17. import {Referrer} from 'sentry/views/performance/cache/referrers';
  18. import {MODULE_TITLE, RELEASE_LEVEL} from 'sentry/views/performance/cache/settings';
  19. import {convertHitRateToMissRate} from 'sentry/views/performance/cache/utils';
  20. import * as ModuleLayout from 'sentry/views/performance/moduleLayout';
  21. import {ModulePageProviders} from 'sentry/views/performance/modulePageProviders';
  22. import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useSpanMetricsSeries';
  23. import type {SpanMetricsQueryFilters} from 'sentry/views/starfish/types';
  24. export function CacheLandingPage() {
  25. const organization = useOrganization();
  26. const filters: SpanMetricsQueryFilters = {
  27. 'span.module': 'cache',
  28. };
  29. const {
  30. isLoading: isCacheHitRateLoading,
  31. data: cacheHitRateData,
  32. error: cacheHitRateError,
  33. } = useSpanMetricsSeries({
  34. yAxis: [`cache_hit_rate()`],
  35. search: MutableSearch.fromQueryObject(filters),
  36. referrer: Referrer.LANDING_CACHE_HIT_MISS_CHART,
  37. });
  38. const {
  39. isLoading: isThroughputDataLoading,
  40. data: throughputData,
  41. error: throughputError,
  42. } = useSpanMetricsSeries({
  43. search: MutableSearch.fromQueryObject(filters),
  44. yAxis: ['spm()'],
  45. referrer: Referrer.LANDING_CACHE_THROUGHPUT_CHART,
  46. });
  47. return (
  48. <React.Fragment>
  49. <Layout.Header>
  50. <Layout.HeaderContent>
  51. <Breadcrumbs
  52. crumbs={[
  53. {
  54. label: t('Performance'),
  55. to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
  56. preservePageFilters: true,
  57. },
  58. {
  59. label: MODULE_TITLE,
  60. },
  61. ]}
  62. />
  63. <Layout.Title>
  64. {MODULE_TITLE}
  65. <FeatureBadge type={RELEASE_LEVEL} />
  66. </Layout.Title>
  67. </Layout.HeaderContent>
  68. <Layout.HeaderActions>
  69. <ButtonBar gap={1}>
  70. <FeedbackWidgetButton />
  71. </ButtonBar>
  72. </Layout.HeaderActions>
  73. </Layout.Header>
  74. <Layout.Body>
  75. <Layout.Main fullWidth>
  76. <ModuleLayout.Layout>
  77. <ModuleLayout.Full>
  78. <PageFilterBar condensed>
  79. <ProjectPageFilter />
  80. <EnvironmentPageFilter />
  81. <DatePageFilter />
  82. </PageFilterBar>
  83. </ModuleLayout.Full>
  84. <ModuleLayout.Half>
  85. <CacheHitMissChart
  86. series={convertHitRateToMissRate(cacheHitRateData['cache_hit_rate()'])}
  87. isLoading={isCacheHitRateLoading}
  88. error={cacheHitRateError}
  89. />
  90. </ModuleLayout.Half>
  91. <ModuleLayout.Half>
  92. <ThroughputChart
  93. series={throughputData['spm()']}
  94. isLoading={isThroughputDataLoading}
  95. error={throughputError}
  96. />
  97. </ModuleLayout.Half>
  98. </ModuleLayout.Layout>
  99. </Layout.Main>
  100. </Layout.Body>
  101. </React.Fragment>
  102. );
  103. }
  104. function LandingPageWithProviders() {
  105. return (
  106. <ModulePageProviders
  107. title={[t('Performance'), MODULE_TITLE].join(' — ')}
  108. baseURL="/performance/cache"
  109. features="performance-cache-view"
  110. >
  111. <CacheLandingPage />
  112. </ModulePageProviders>
  113. );
  114. }
  115. export default LandingPageWithProviders;