index.tsx 5.2 KB

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