123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- import React, {Fragment} from 'react';
- import Alert from 'sentry/components/alert';
- import ProjectAvatar from 'sentry/components/avatar/projectAvatar';
- import {Breadcrumbs} from 'sentry/components/breadcrumbs';
- import ButtonBar from 'sentry/components/buttonBar';
- import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
- import * as Layout from 'sentry/components/layouts/thirds';
- import ExternalLink from 'sentry/components/links/externalLink';
- import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
- import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
- import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
- import {t, tct} from 'sentry/locale';
- import {DurationUnit, RateUnit} from 'sentry/utils/discover/fields';
- import {decodeList, decodeScalar, decodeSorts} from 'sentry/utils/queryString';
- import {
- EMPTY_OPTION_VALUE,
- escapeFilterValue,
- MutableSearch,
- } from 'sentry/utils/tokenizeSearch';
- import useLocationQuery from 'sentry/utils/url/useLocationQuery';
- import {useLocation} from 'sentry/utils/useLocation';
- import useProjects from 'sentry/utils/useProjects';
- import {useSynchronizeCharts} from 'sentry/views/insights/common/components/chart';
- import {HeaderContainer} from 'sentry/views/insights/common/components/headerContainer';
- import {MetricReadout} from 'sentry/views/insights/common/components/metricReadout';
- import * as ModuleLayout from 'sentry/views/insights/common/components/moduleLayout';
- import {ModulePageProviders} from 'sentry/views/insights/common/components/modulePageProviders';
- import {ReadoutRibbon, ToolRibbon} from 'sentry/views/insights/common/components/ribbon';
- import {getTimeSpentExplanation} from 'sentry/views/insights/common/components/tableCells/timeSpentCell';
- import {useSpanMetrics} from 'sentry/views/insights/common/queries/useDiscover';
- import {useSpanMetricsSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
- import {useModuleBreadcrumbs} from 'sentry/views/insights/common/utils/useModuleBreadcrumbs';
- import {QueryParameterNames} from 'sentry/views/insights/common/views/queryParameters';
- import SubregionSelector from 'sentry/views/insights/common/views/spans/selectors/subregionSelector';
- import {
- DataTitles,
- getThroughputTitle,
- } from 'sentry/views/insights/common/views/spans/types';
- import {DurationChart} from 'sentry/views/insights/http/components/charts/durationChart';
- import {ResponseRateChart} from 'sentry/views/insights/http/components/charts/responseRateChart';
- import {ThroughputChart} from 'sentry/views/insights/http/components/charts/throughputChart';
- import {DomainStatusLink} from 'sentry/views/insights/http/components/domainStatusLink';
- import {HTTPSamplesPanel} from 'sentry/views/insights/http/components/httpSamplesPanel';
- import {
- DomainTransactionsTable,
- isAValidSort,
- } from 'sentry/views/insights/http/components/tables/domainTransactionsTable';
- import {Referrer} from 'sentry/views/insights/http/referrers';
- import {
- BASE_FILTERS,
- MODULE_DOC_LINK,
- NULL_DOMAIN_DESCRIPTION,
- } from 'sentry/views/insights/http/settings';
- import {BackendHeader} from 'sentry/views/insights/pages/backend/backendPageHeader';
- import {BACKEND_LANDING_SUB_PATH} from 'sentry/views/insights/pages/backend/settings';
- import {FrontendHeader} from 'sentry/views/insights/pages/frontend/frontendPageHeader';
- import {FRONTEND_LANDING_SUB_PATH} from 'sentry/views/insights/pages/frontend/settings';
- import {useDomainViewFilters} from 'sentry/views/insights/pages/useFilters';
- import type {SpanMetricsQueryFilters} from 'sentry/views/insights/types';
- import {ModuleName, SpanFunction, SpanMetricsField} from 'sentry/views/insights/types';
- type Query = {
- aggregate?: string;
- domain?: string;
- };
- export function HTTPDomainSummaryPage() {
- const location = useLocation<Query>();
- const {projects} = useProjects();
- const {isInDomainView, view} = useDomainViewFilters();
- // TODO: Fetch sort information using `useLocationQuery`
- const sortField = decodeScalar(location.query?.[QueryParameterNames.TRANSACTIONS_SORT]);
- const sort = decodeSorts(sortField).filter(isAValidSort).at(0) ?? DEFAULT_SORT;
- const {
- domain,
- project: projectId,
- 'user.geo.subregion': subregions,
- } = useLocationQuery({
- fields: {
- project: decodeScalar,
- domain: decodeScalar,
- [SpanMetricsField.USER_GEO_SUBREGION]: decodeList,
- },
- });
- const project = projects.find(p => projectId === p.id);
- const filters: SpanMetricsQueryFilters = {
- ...BASE_FILTERS,
- 'span.domain': domain === '' ? EMPTY_OPTION_VALUE : escapeFilterValue(domain),
- ...(subregions.length > 0
- ? {
- [SpanMetricsField.USER_GEO_SUBREGION]: `[${subregions.join(',')}]`,
- }
- : {}),
- };
- const cursor = decodeScalar(location.query?.[QueryParameterNames.TRANSACTIONS_CURSOR]);
- const {data: domainMetrics, isPending: 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}()`,
- ],
- },
- Referrer.DOMAIN_SUMMARY_METRICS_RIBBON
- );
- const {
- isPending: isThroughputDataLoading,
- data: throughputData,
- error: throughputError,
- } = useSpanMetricsSeries(
- {
- search: MutableSearch.fromQueryObject(filters),
- yAxis: ['spm()'],
- },
- Referrer.DOMAIN_SUMMARY_THROUGHPUT_CHART
- );
- const {
- isPending: isDurationDataLoading,
- data: durationData,
- error: durationError,
- } = useSpanMetricsSeries(
- {
- search: MutableSearch.fromQueryObject(filters),
- yAxis: [`avg(${SpanMetricsField.SPAN_SELF_TIME})`],
- },
- Referrer.DOMAIN_SUMMARY_DURATION_CHART
- );
- const {
- isPending: isResponseCodeDataLoading,
- data: responseCodeData,
- error: responseCodeError,
- } = useSpanMetricsSeries(
- {
- search: MutableSearch.fromQueryObject(filters),
- yAxis: ['http_response_rate(3)', 'http_response_rate(4)', 'http_response_rate(5)'],
- },
- Referrer.DOMAIN_SUMMARY_RESPONSE_CODE_CHART
- );
- const {
- isPending: 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.DOMAIN_SUMMARY_TRANSACTIONS_LIST
- );
- useSynchronizeCharts(
- 3,
- !isThroughputDataLoading && !isDurationDataLoading && !isResponseCodeDataLoading
- );
- const crumbs = useModuleBreadcrumbs('http');
- const headerTitle = (
- <Fragment>
- {project && <ProjectAvatar project={project} size={36} />}
- {domain || NULL_DOMAIN_DESCRIPTION}
- <DomainStatusLink domain={domain} />
- </Fragment>
- );
- return (
- <React.Fragment>
- {!isInDomainView && (
- <Layout.Header>
- <Layout.HeaderContent>
- <Breadcrumbs
- crumbs={[
- ...crumbs,
- {
- label: t('Domain Summary'),
- },
- ]}
- />
- <Layout.Title>
- {project && <ProjectAvatar project={project} size={36} />}
- {domain || NULL_DOMAIN_DESCRIPTION}
- <DomainStatusLink domain={domain} />
- </Layout.Title>
- </Layout.HeaderContent>
- <Layout.HeaderActions>
- <ButtonBar gap={1}>
- <FeedbackWidgetButton />
- </ButtonBar>
- </Layout.HeaderActions>
- </Layout.Header>
- )}
- {isInDomainView && view === FRONTEND_LANDING_SUB_PATH && (
- <FrontendHeader
- headerTitle={
- <Fragment>
- {project && <ProjectAvatar project={project} size={36} />}
- {domain || NULL_DOMAIN_DESCRIPTION}
- <DomainStatusLink domain={domain} />
- </Fragment>
- }
- breadcrumbs={[
- {
- label: 'Domain Summary',
- },
- ]}
- module={ModuleName.HTTP}
- />
- )}
- {isInDomainView && view === BACKEND_LANDING_SUB_PATH && (
- <BackendHeader
- headerTitle={headerTitle}
- module={ModuleName.HTTP}
- breadcrumbs={[
- {
- label: t('Domain Summary'),
- },
- ]}
- />
- )}
- <Layout.Body>
- <Layout.Main fullWidth>
- {domain === '' && (
- <Alert type="info">
- {tct(
- '"Unknown Domain" entries can be caused by instrumentation errors. Please refer to our [link] for more information.',
- {
- link: <ExternalLink href={MODULE_DOC_LINK}>documentation</ExternalLink>,
- }
- )}
- </Alert>
- )}
- <ModuleLayout.Layout>
- <ModuleLayout.Full>
- <HeaderContainer>
- <ToolRibbon>
- <PageFilterBar condensed>
- <EnvironmentPageFilter />
- <DatePageFilter />
- </PageFilterBar>
- <SubregionSelector />
- </ToolRibbon>
- <ReadoutRibbon>
- <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()'],
- 'http'
- )}
- isLoading={areDomainMetricsLoading}
- />
- </ReadoutRibbon>
- </HeaderContainer>
- </ModuleLayout.Full>
- <ModuleLayout.Third>
- <ThroughputChart
- series={throughputData['spm()']}
- isLoading={isThroughputDataLoading}
- error={throughputError}
- filters={filters}
- />
- </ModuleLayout.Third>
- <ModuleLayout.Third>
- <DurationChart
- series={[durationData[`avg(${SpanMetricsField.SPAN_SELF_TIME})`]]}
- isLoading={isDurationDataLoading}
- error={durationError}
- filters={filters}
- />
- </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}
- filters={filters}
- />
- </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;
- function PageWithProviders() {
- return (
- <ModulePageProviders
- moduleName="http"
- pageTitle={t('Domain Summary')}
- features="insights-initial-modules"
- >
- <HTTPDomainSummaryPage />
- </ModulePageProviders>
- );
- }
- export default PageWithProviders;
|