index.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import {useMemo, useState} from 'react';
  2. import * as Layout from 'sentry/components/layouts/thirds';
  3. import NoProjectMessage from 'sentry/components/noProjectMessage';
  4. import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
  5. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  6. import {t} from 'sentry/locale';
  7. import {TraceFullDetailedQuery} from 'sentry/utils/performance/quickTrace/traceFullQuery';
  8. import {decodeScalar} from 'sentry/utils/queryString';
  9. import {useLocation} from 'sentry/utils/useLocation';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. import {useParams} from 'sentry/utils/useParams';
  12. import {Trace} from './trace';
  13. const DOCUMENT_TITLE = [t('Trace Details'), t('Performance')].join(' — ');
  14. export function TraceView() {
  15. const location = useLocation();
  16. const organization = useOrganization();
  17. const params = useParams<{traceSlug?: string}>();
  18. const traceSlug = params.traceSlug?.trim() ?? '';
  19. const dateSelection = useMemo(() => {
  20. const queryParams = normalizeDateTimeParams(location.query, {
  21. allowAbsolutePageDatetime: true,
  22. });
  23. const start = decodeScalar(queryParams.start);
  24. const end = decodeScalar(queryParams.end);
  25. const statsPeriod = decodeScalar(queryParams.statsPeriod);
  26. return {start, end, statsPeriod};
  27. }, [location.query]);
  28. // @TODO pass this to children
  29. // const _traceEventView = useMemo(() => {
  30. // const {start, end, statsPeriod} = dateSelection;
  31. // return EventView.fromSavedQuery({
  32. // id: undefined,
  33. // name: `Events with Trace ID ${traceSlug}`,
  34. // fields: ['title', 'event.type', 'project', 'timestamp'],
  35. // orderby: '-timestamp',
  36. // query: `trace:${traceSlug}`,
  37. // projects: [ALL_ACCESS_PROJECTS],
  38. // version: 2,
  39. // start,
  40. // end,
  41. // range: statsPeriod,
  42. // });
  43. // }, []);
  44. const [_limit, _setLimit] = useState<number>();
  45. // const _handleLimithange = useCallback((newLimit: number) => {
  46. // setLimit(newLimit);
  47. // }, []);
  48. return (
  49. <SentryDocumentTitle title={DOCUMENT_TITLE} orgSlug={organization.slug}>
  50. <Layout.Page>
  51. <NoProjectMessage organization={organization}>
  52. <TraceFullDetailedQuery
  53. location={location}
  54. orgSlug={organization.slug}
  55. traceId={traceSlug}
  56. start={dateSelection.start}
  57. end={dateSelection.end}
  58. statsPeriod={dateSelection.statsPeriod}
  59. >
  60. {trace => <Trace trace={trace?.traces} trace_id={traceSlug} />}
  61. </TraceFullDetailedQuery>
  62. </NoProjectMessage>
  63. </Layout.Page>
  64. </SentryDocumentTitle>
  65. );
  66. }