index.tsx 5.7 KB

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