index.tsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {Fragment, useMemo} from 'react';
  2. import type {Tag} from 'sentry/actionCreators/events';
  3. import type {ApiResult} from 'sentry/api';
  4. import type {EventTransaction} from 'sentry/types/event';
  5. import type EventView from 'sentry/utils/discover/eventView';
  6. import type {
  7. TraceFullDetailed,
  8. TraceSplitResults,
  9. } from 'sentry/utils/performance/quickTrace/types';
  10. import type {UseApiQueryResult, UseInfiniteQueryResult} from 'sentry/utils/queryClient';
  11. import type RequestError from 'sentry/utils/requestError/requestError';
  12. import {useLocation} from 'sentry/utils/useLocation';
  13. import useOrganization from 'sentry/utils/useOrganization';
  14. import {isTraceNode} from '../../../guards';
  15. import type {TraceMetaQueryResults} from '../../../traceApi/useTraceMeta';
  16. import type {TraceTree, TraceTreeNode} from '../../../traceModels/traceTree';
  17. import type {TraceType} from '../../../traceType';
  18. import {IssueList} from '../../details/issues/issues';
  19. import {TraceDrawerComponents} from '../../details/styles';
  20. import {GeneralInfo} from './generalInfo';
  21. import {TagsSummary} from './tagsSummary';
  22. type TraceDetailsProps = {
  23. metaResults: TraceMetaQueryResults;
  24. node: TraceTreeNode<TraceTree.NodeValue> | null;
  25. rootEventResults: UseApiQueryResult<EventTransaction, RequestError>;
  26. tagsInfiniteQueryResults: UseInfiniteQueryResult<ApiResult<Tag[]>, unknown>;
  27. traceEventView: EventView;
  28. traceType: TraceType;
  29. traces: TraceSplitResults<TraceFullDetailed> | null;
  30. tree: TraceTree;
  31. };
  32. export function TraceDetails(props: TraceDetailsProps) {
  33. const location = useLocation();
  34. const organization = useOrganization();
  35. const issues = useMemo(() => {
  36. if (!props.node) {
  37. return [];
  38. }
  39. return [...props.node.errors, ...props.node.performance_issues];
  40. // eslint-disable-next-line react-hooks/exhaustive-deps
  41. }, [props.node, props.node?.errors.size, props.node?.performance_issues.size]);
  42. if (!props.node) {
  43. return null;
  44. }
  45. if (!(props.node && isTraceNode(props.node))) {
  46. throw new Error('Expected a trace node');
  47. }
  48. return (
  49. <Fragment>
  50. <IssueList issues={issues} node={props.node} organization={organization} />
  51. <TraceDrawerComponents.SectionCardGroup>
  52. <GeneralInfo
  53. organization={organization}
  54. traces={props.traces}
  55. tree={props.tree}
  56. node={props.node}
  57. rootEventResults={props.rootEventResults}
  58. metaResults={props.metaResults}
  59. />
  60. <TagsSummary
  61. tagsInfiniteQueryResults={props.tagsInfiniteQueryResults}
  62. organization={organization}
  63. location={location}
  64. eventView={props.traceEventView}
  65. totalValues={props.tree.eventsCount}
  66. />
  67. </TraceDrawerComponents.SectionCardGroup>
  68. </Fragment>
  69. );
  70. }