trace.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {Fragment, useMemo} from 'react';
  2. import type {Tag} from 'sentry/actionCreators/events';
  3. import type {EventTransaction, Organization} from 'sentry/types';
  4. import {generateQueryWithTag} from 'sentry/utils';
  5. import type EventView from 'sentry/utils/discover/eventView';
  6. import {formatTagKey} from 'sentry/utils/discover/fields';
  7. import type {
  8. TraceFullDetailed,
  9. TraceSplitResults,
  10. } from 'sentry/utils/performance/quickTrace/types';
  11. import type {UseApiQueryResult} from 'sentry/utils/queryClient';
  12. import type RequestError from 'sentry/utils/requestError/requestError';
  13. import {useLocation} from 'sentry/utils/useLocation';
  14. import Tags from 'sentry/views/discover/tags';
  15. import {isTraceNode} from '../../guards';
  16. import type {TraceTree, TraceTreeNode} from '../../traceTree';
  17. import {IssueList} from '../details/issues/issues';
  18. type TraceDetailsProps = {
  19. node: TraceTreeNode<TraceTree.NodeValue> | null;
  20. organization: Organization;
  21. rootEventResults: UseApiQueryResult<EventTransaction, RequestError>;
  22. tagsQueryResults: UseApiQueryResult<Tag[], RequestError>;
  23. traceEventView: EventView;
  24. traces: TraceSplitResults<TraceFullDetailed> | null;
  25. tree: TraceTree;
  26. };
  27. export function TraceDetails(props: TraceDetailsProps) {
  28. const location = useLocation();
  29. const issues = useMemo(() => {
  30. if (!props.node) {
  31. return [];
  32. }
  33. return [...props.node.errors, ...props.node.performance_issues];
  34. }, [props.node]);
  35. if (!props.node) {
  36. return null;
  37. }
  38. if (!(props.node && isTraceNode(props.node))) {
  39. throw new Error('Expected a trace node');
  40. }
  41. const {data: rootEvent} = props.rootEventResults;
  42. return (
  43. <Fragment>
  44. <IssueList issues={issues} node={props.node} organization={props.organization} />
  45. {rootEvent ? (
  46. <Tags
  47. tagsQueryResults={props.tagsQueryResults}
  48. generateUrl={(key: string, value: string) => {
  49. const url = props.traceEventView.getResultsViewUrlTarget(
  50. props.organization.slug,
  51. false
  52. );
  53. url.query = generateQueryWithTag(url.query, {
  54. key: formatTagKey(key),
  55. value,
  56. });
  57. return url;
  58. }}
  59. totalValues={props.tree.eventsCount}
  60. eventView={props.traceEventView}
  61. organization={props.organization}
  62. location={location}
  63. />
  64. ) : null}
  65. </Fragment>
  66. );
  67. }