123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- import React from 'react';
- import styled from '@emotion/styled';
- import ProjectAvatar from 'sentry/components/avatar/projectAvatar';
- import {Breadcrumbs} from 'sentry/components/breadcrumbs';
- import FeatureBadge from 'sentry/components/featureBadge';
- import FloatingFeedbackWidget from 'sentry/components/feedback/widget/floatingFeedbackWidget';
- import * as Layout from 'sentry/components/layouts/thirds';
- import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
- import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
- import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
- import {t} from 'sentry/locale';
- import {space} from 'sentry/styles/space';
- import {fromSorts} from 'sentry/utils/discover/eventView';
- import {DurationUnit, RateUnit} from 'sentry/utils/discover/fields';
- import {decodeScalar} from 'sentry/utils/queryString';
- import {MutableSearch} from 'sentry/utils/tokenizeSearch';
- import useLocationQuery from 'sentry/utils/url/useLocationQuery';
- import {useLocation} from 'sentry/utils/useLocation';
- import useOrganization from 'sentry/utils/useOrganization';
- import useProjects from 'sentry/utils/useProjects';
- import {normalizeUrl} from 'sentry/utils/withDomainRequired';
- import {
- DomainTransactionsTable,
- isAValidSort,
- } from 'sentry/views/performance/http/domainTransactionsTable';
- import {DurationChart} from 'sentry/views/performance/http/durationChart';
- import {HTTPSamplesPanel} from 'sentry/views/performance/http/httpSamplesPanel';
- import {ResponseRateChart} from 'sentry/views/performance/http/responseRateChart';
- import {RELEASE_LEVEL} from 'sentry/views/performance/http/settings';
- import {ThroughputChart} from 'sentry/views/performance/http/throughputChart';
- import {MetricReadout} from 'sentry/views/performance/metricReadout';
- import * as ModuleLayout from 'sentry/views/performance/moduleLayout';
- import {ModulePageProviders} from 'sentry/views/performance/modulePageProviders';
- import {useSynchronizeCharts} from 'sentry/views/starfish/components/chart';
- import {getTimeSpentExplanation} from 'sentry/views/starfish/components/tableCells/timeSpentCell';
- import {useSpanMetrics} from 'sentry/views/starfish/queries/useSpanMetrics';
- import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useSpanMetricsSeries';
- import type {SpanMetricsQueryFilters} from 'sentry/views/starfish/types';
- import {ModuleName, SpanFunction, SpanMetricsField} from 'sentry/views/starfish/types';
- import {QueryParameterNames} from 'sentry/views/starfish/views/queryParameters';
- import {DataTitles, getThroughputTitle} from 'sentry/views/starfish/views/spans/types';
- type Query = {
- aggregate?: string;
- domain?: string;
- };
- export function HTTPDomainSummaryPage() {
- const location = useLocation<Query>();
- const organization = useOrganization();
- const {projects} = useProjects();
- // TODO: Fetch sort information using `useLocationQuery`
- const sortField = decodeScalar(location.query?.[QueryParameterNames.TRANSACTIONS_SORT]);
- const sort = fromSorts(sortField).filter(isAValidSort).at(0) ?? DEFAULT_SORT;
- const {domain, project: projectId} = useLocationQuery({
- fields: {
- project: decodeScalar,
- domain: decodeScalar,
- },
- });
- const project = projects.find(p => projectId === p.id);
- const filters: SpanMetricsQueryFilters = {
- 'span.module': ModuleName.HTTP,
- 'span.domain': domain,
- };
- const cursor = decodeScalar(location.query?.[QueryParameterNames.TRANSACTIONS_CURSOR]);
- const {data: domainMetrics, isLoading: areDomainMetricsLoading} = useSpanMetrics({
- search: MutableSearch.fromQueryObject(filters),
- fields: [
- `${SpanFunction.SPM}()`,
- `avg(${SpanMetricsField.SPAN_SELF_TIME})`,
- `sum(${SpanMetricsField.SPAN_SELF_TIME})`,
- 'http_response_rate(3)',
- 'http_response_rate(4)',
- 'http_response_rate(5)',
- `${SpanFunction.TIME_SPENT_PERCENTAGE}()`,
- ],
- enabled: Boolean(domain),
- referrer: 'api.starfish.http-module-domain-summary-metrics-ribbon',
- });
- const {
- isLoading: isThroughputDataLoading,
- data: throughputData,
- error: throughputError,
- } = useSpanMetricsSeries({
- search: MutableSearch.fromQueryObject(filters),
- yAxis: ['spm()'],
- enabled: Boolean(domain),
- referrer: 'api.starfish.http-module-domain-summary-throughput-chart',
- });
- const {
- isLoading: isDurationDataLoading,
- data: durationData,
- error: durationError,
- } = useSpanMetricsSeries({
- search: MutableSearch.fromQueryObject(filters),
- yAxis: [`avg(${SpanMetricsField.SPAN_SELF_TIME})`],
- enabled: Boolean(domain),
- referrer: 'api.starfish.http-module-domain-summary-duration-chart',
- });
- const {
- isLoading: isResponseCodeDataLoading,
- data: responseCodeData,
- error: responseCodeError,
- } = useSpanMetricsSeries({
- search: MutableSearch.fromQueryObject(filters),
- yAxis: ['http_response_rate(3)', 'http_response_rate(4)', 'http_response_rate(5)'],
- referrer: 'api.starfish.http-module-domain-summary-response-code-chart',
- });
- const {
- isLoading: isTransactionsListLoading,
- data: transactionsList,
- meta: transactionsListMeta,
- error: transactionsListError,
- pageLinks: transactionsListPageLinks,
- } = useSpanMetrics({
- search: MutableSearch.fromQueryObject(filters),
- fields: [
- 'project.id',
- 'transaction',
- 'transaction.method',
- 'spm()',
- 'http_response_rate(3)',
- 'http_response_rate(4)',
- 'http_response_rate(5)',
- 'avg(span.self_time)',
- 'sum(span.self_time)',
- 'time_spent_percentage()',
- ],
- sorts: [sort],
- limit: TRANSACTIONS_TABLE_ROW_COUNT,
- cursor,
- referrer: 'api.starfish.http-module-domain-summary-transactions-list',
- });
- useSynchronizeCharts([!isThroughputDataLoading && !isDurationDataLoading]);
- return (
- <React.Fragment>
- <Layout.Header>
- <Layout.HeaderContent>
- <Breadcrumbs
- crumbs={[
- {
- label: 'Performance',
- to: normalizeUrl(`/organizations/${organization.slug}/performance/`),
- preservePageFilters: true,
- },
- {
- label: 'HTTP',
- to: normalizeUrl(`/organizations/${organization.slug}/performance/http`),
- preservePageFilters: true,
- },
- {
- label: 'Domain Summary',
- },
- ]}
- />
- <Layout.Title>
- {project && <ProjectAvatar project={project} size={36} />}
- {domain}
- <FeatureBadge type={RELEASE_LEVEL} />
- </Layout.Title>
- </Layout.HeaderContent>
- </Layout.Header>
- <Layout.Body>
- <Layout.Main fullWidth>
- <FloatingFeedbackWidget />
- <ModuleLayout.Layout>
- <ModuleLayout.Full>
- <HeaderContainer>
- <PageFilterBar condensed>
- <EnvironmentPageFilter />
- <DatePageFilter />
- </PageFilterBar>
- <MetricsRibbon>
- <MetricReadout
- title={getThroughputTitle('http')}
- value={domainMetrics?.[0]?.[`${SpanFunction.SPM}()`]}
- unit={RateUnit.PER_MINUTE}
- isLoading={areDomainMetricsLoading}
- />
- <MetricReadout
- title={DataTitles.avg}
- value={
- domainMetrics?.[0]?.[`avg(${SpanMetricsField.SPAN_SELF_TIME})`]
- }
- unit={DurationUnit.MILLISECOND}
- isLoading={areDomainMetricsLoading}
- />
- <MetricReadout
- title={t('3XXs')}
- value={domainMetrics?.[0]?.[`http_response_rate(3)`]}
- unit="percentage"
- isLoading={areDomainMetricsLoading}
- />
- <MetricReadout
- title={t('4XXs')}
- value={domainMetrics?.[0]?.[`http_response_rate(4)`]}
- unit="percentage"
- isLoading={areDomainMetricsLoading}
- />
- <MetricReadout
- title={t('5XXs')}
- value={domainMetrics?.[0]?.[`http_response_rate(5)`]}
- unit="percentage"
- isLoading={areDomainMetricsLoading}
- />
- <MetricReadout
- title={DataTitles.timeSpent}
- value={domainMetrics?.[0]?.['sum(span.self_time)']}
- unit={DurationUnit.MILLISECOND}
- tooltip={getTimeSpentExplanation(
- domainMetrics?.[0]?.['time_spent_percentage()'],
- 'db'
- )}
- isLoading={areDomainMetricsLoading}
- />
- </MetricsRibbon>
- </HeaderContainer>
- </ModuleLayout.Full>
- <ModuleLayout.Third>
- <ThroughputChart
- series={throughputData['spm()']}
- isLoading={isThroughputDataLoading}
- error={throughputError}
- />
- </ModuleLayout.Third>
- <ModuleLayout.Third>
- <DurationChart
- series={durationData[`avg(${SpanMetricsField.SPAN_SELF_TIME})`]}
- isLoading={isDurationDataLoading}
- error={durationError}
- />
- </ModuleLayout.Third>
- <ModuleLayout.Third>
- <ResponseRateChart
- series={[
- {
- ...responseCodeData[`http_response_rate(3)`],
- seriesName: t('3XX'),
- },
- {
- ...responseCodeData[`http_response_rate(4)`],
- seriesName: t('4XX'),
- },
- {
- ...responseCodeData[`http_response_rate(5)`],
- seriesName: t('5XX'),
- },
- ]}
- isLoading={isResponseCodeDataLoading}
- error={responseCodeError}
- />
- </ModuleLayout.Third>
- <ModuleLayout.Full>
- <DomainTransactionsTable
- domain={domain}
- data={transactionsList}
- error={transactionsListError}
- isLoading={isTransactionsListLoading}
- meta={transactionsListMeta}
- pageLinks={transactionsListPageLinks}
- sort={sort}
- />
- </ModuleLayout.Full>
- </ModuleLayout.Layout>
- </Layout.Main>
- </Layout.Body>
- <HTTPSamplesPanel />
- </React.Fragment>
- );
- }
- const DEFAULT_SORT = {
- field: 'time_spent_percentage()' as const,
- kind: 'desc' as const,
- };
- const TRANSACTIONS_TABLE_ROW_COUNT = 20;
- const HeaderContainer = styled('div')`
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- `;
- const MetricsRibbon = styled('div')`
- display: flex;
- flex-wrap: wrap;
- gap: ${space(4)};
- `;
- function LandingPageWithProviders() {
- return (
- <ModulePageProviders
- baseURL="/performance/http"
- title={[t('Performance'), t('HTTP'), t('Domain Summary')].join(' — ')}
- features="performance-http-view"
- >
- <HTTPDomainSummaryPage />
- </ModulePageProviders>
- );
- }
- export default LandingPageWithProviders;
|