index.tsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import {useMemo} from 'react';
  2. import {EventContexts} from 'sentry/components/events/contexts';
  3. import {SpanProfileDetails} from 'sentry/components/events/interfaces/spans/spanProfileDetails';
  4. import {getSpanOperation} from 'sentry/components/events/interfaces/spans/utils';
  5. import ProjectBadge from 'sentry/components/idBadge/projectBadge';
  6. import {CustomMetricsEventData} from 'sentry/components/metrics/customMetricsEventData';
  7. import {Tooltip} from 'sentry/components/tooltip';
  8. import {t} from 'sentry/locale';
  9. import type {Organization} from 'sentry/types/organization';
  10. import type {Project} from 'sentry/types/project';
  11. import {useLocation} from 'sentry/utils/useLocation';
  12. import useProjects from 'sentry/utils/useProjects';
  13. import type {TraceTreeNodeDetailsProps} from 'sentry/views/performance/newTraceDetails/traceDrawer/tabs/traceTreeNodeDetails';
  14. import type {
  15. TraceTree,
  16. TraceTreeNode,
  17. } from 'sentry/views/performance/newTraceDetails/traceModels/traceTree';
  18. import {ProfileGroupProvider} from 'sentry/views/profiling/profileGroupProvider';
  19. import {ProfileContext, ProfilesProvider} from 'sentry/views/profiling/profilesProvider';
  20. import {TraceDrawerComponents} from '.././styles';
  21. import {IssueList} from '../issues/issues';
  22. import Alerts from './sections/alerts';
  23. import {SpanDescription} from './sections/description';
  24. import {GeneralInfo} from './sections/generalInfo';
  25. import {SpanHTTPInfo} from './sections/http';
  26. import {SpanKeys} from './sections/keys';
  27. import {Tags} from './sections/tags';
  28. function SpanNodeDetailHeader({
  29. node,
  30. organization,
  31. onTabScrollToNode,
  32. project,
  33. }: {
  34. node: TraceTreeNode<TraceTree.Span>;
  35. onTabScrollToNode: (node: TraceTreeNode<any>) => void;
  36. organization: Organization;
  37. project: Project | undefined;
  38. }) {
  39. const span = node.value;
  40. return (
  41. <TraceDrawerComponents.HeaderContainer>
  42. <TraceDrawerComponents.Title>
  43. <Tooltip title={span.event.projectSlug}>
  44. <ProjectBadge
  45. project={project ? project : {slug: span.event.projectSlug || ''}}
  46. avatarSize={30}
  47. hideName
  48. />
  49. </Tooltip>
  50. <TraceDrawerComponents.TitleText>
  51. <div>{t('span')}</div>
  52. <TraceDrawerComponents.TitleOp
  53. text={getSpanOperation(span) + ' - ' + (span.description ?? span.span_id)}
  54. />
  55. </TraceDrawerComponents.TitleText>
  56. </TraceDrawerComponents.Title>
  57. <TraceDrawerComponents.NodeActions
  58. node={node}
  59. organization={organization}
  60. onTabScrollToNode={onTabScrollToNode}
  61. />
  62. </TraceDrawerComponents.HeaderContainer>
  63. );
  64. }
  65. export function SpanNodeDetails({
  66. node,
  67. organization,
  68. onTabScrollToNode,
  69. onParentClick,
  70. }: TraceTreeNodeDetailsProps<TraceTreeNode<TraceTree.Span>>) {
  71. const location = useLocation();
  72. const {projects} = useProjects();
  73. const issues = useMemo(() => {
  74. return [...node.errors, ...node.performance_issues];
  75. }, [node.errors, node.performance_issues]);
  76. const project = projects.find(proj => proj.slug === node.value.event?.projectSlug);
  77. const profileId = node.value.event?.contexts?.profile?.profile_id ?? null;
  78. return (
  79. <TraceDrawerComponents.DetailContainer>
  80. <SpanNodeDetailHeader
  81. node={node}
  82. organization={organization}
  83. project={project}
  84. onTabScrollToNode={onTabScrollToNode}
  85. />
  86. {node.value.event.projectSlug ? (
  87. <ProfilesProvider
  88. orgSlug={organization.slug}
  89. projectSlug={node.value.event.projectSlug}
  90. profileId={profileId || ''}
  91. >
  92. <ProfileContext.Consumer>
  93. {profiles => (
  94. <ProfileGroupProvider
  95. type="flamechart"
  96. input={profiles?.type === 'resolved' ? profiles.data : null}
  97. traceID={profileId || ''}
  98. >
  99. <Alerts node={node} />
  100. {issues.length > 0 ? (
  101. <IssueList organization={organization} issues={issues} node={node} />
  102. ) : null}
  103. <TraceDrawerComponents.SectionCardGroup>
  104. <SpanDescription
  105. node={node}
  106. organization={organization}
  107. location={location}
  108. />
  109. <GeneralInfo
  110. node={node}
  111. organization={organization}
  112. location={location}
  113. onParentClick={onParentClick}
  114. />
  115. <SpanHTTPInfo span={node.value} />
  116. <Tags span={node.value} />
  117. <SpanKeys projectId={project?.id} node={node} />
  118. <CustomMetricsEventData
  119. projectId={project?.id || ''}
  120. metricsSummary={node.value._metrics_summary}
  121. startTimestamp={node.value.start_timestamp}
  122. />
  123. </TraceDrawerComponents.SectionCardGroup>
  124. <EventContexts event={node.value.event} />
  125. {organization.features.includes('profiling') ? (
  126. <SpanProfileDetails span={node.value} event={node.value.event} />
  127. ) : null}
  128. </ProfileGroupProvider>
  129. )}
  130. </ProfileContext.Consumer>
  131. </ProfilesProvider>
  132. ) : null}
  133. </TraceDrawerComponents.DetailContainer>
  134. );
  135. }