span.tsx 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import {Button} from 'sentry/components/button';
  2. import NewTraceDetailsSpanDetail from 'sentry/components/events/interfaces/spans/newTraceDetailsSpanDetails';
  3. import {
  4. getSpanOperation,
  5. parseTrace,
  6. } from 'sentry/components/events/interfaces/spans/utils';
  7. import ProjectBadge from 'sentry/components/idBadge/projectBadge';
  8. import {Tooltip} from 'sentry/components/tooltip';
  9. import {t} from 'sentry/locale';
  10. import useProjects from 'sentry/utils/useProjects';
  11. import type {TraceTreeNodeDetailsProps} from 'sentry/views/performance/newTraceDetails/traceDrawer/tabs/traceTreeNodeDetails';
  12. import type {
  13. TraceTree,
  14. TraceTreeNode,
  15. } from 'sentry/views/performance/newTraceDetails/traceTree';
  16. import {ProfileGroupProvider} from 'sentry/views/profiling/profileGroupProvider';
  17. import {ProfileContext, ProfilesProvider} from 'sentry/views/profiling/profilesProvider';
  18. import {TraceDrawerComponents} from './styles';
  19. export function SpanNodeDetails({
  20. node,
  21. organization,
  22. scrollToNode,
  23. onParentClick,
  24. }: TraceTreeNodeDetailsProps<TraceTreeNode<TraceTree.Span>>) {
  25. const {projects} = useProjects();
  26. const {event, childTransaction, ...span} = node.value;
  27. const project = projects.find(proj => proj.slug === event?.projectSlug);
  28. const profileId = event?.contexts?.profile?.profile_id ?? null;
  29. return (
  30. <TraceDrawerComponents.DetailContainer>
  31. <TraceDrawerComponents.HeaderContainer>
  32. <TraceDrawerComponents.Title>
  33. <Tooltip title={event.projectSlug}>
  34. <ProjectBadge
  35. project={project ? project : {slug: event.projectSlug || ''}}
  36. avatarSize={30}
  37. hideName
  38. />
  39. </Tooltip>
  40. <TraceDrawerComponents.TitleText>
  41. <div>{t('span')}</div>
  42. <TraceDrawerComponents.TitleOp>
  43. {' '}
  44. {getSpanOperation(span)}
  45. </TraceDrawerComponents.TitleOp>
  46. </TraceDrawerComponents.TitleText>
  47. </TraceDrawerComponents.Title>
  48. <TraceDrawerComponents.Actions>
  49. <Button size="xs" onClick={_e => scrollToNode(node)}>
  50. {t('Show in view')}
  51. </Button>
  52. <TraceDrawerComponents.EventDetailsLink
  53. eventId={node.value.event.eventID}
  54. projectSlug={node.metadata.project_slug}
  55. />
  56. </TraceDrawerComponents.Actions>
  57. </TraceDrawerComponents.HeaderContainer>
  58. {event.projectSlug ? (
  59. <ProfilesProvider
  60. orgSlug={organization.slug}
  61. projectSlug={event.projectSlug}
  62. profileId={profileId || ''}
  63. >
  64. <ProfileContext.Consumer>
  65. {profiles => (
  66. <ProfileGroupProvider
  67. type="flamechart"
  68. input={profiles?.type === 'resolved' ? profiles.data : null}
  69. traceID={profileId || ''}
  70. >
  71. <NewTraceDetailsSpanDetail
  72. node={node}
  73. childTransactions={childTransaction ? [childTransaction] : []}
  74. event={event}
  75. openPanel="open"
  76. organization={organization}
  77. span={span}
  78. trace={parseTrace(event)}
  79. onParentClick={onParentClick}
  80. />
  81. </ProfileGroupProvider>
  82. )}
  83. </ProfileContext.Consumer>
  84. </ProfilesProvider>
  85. ) : null}
  86. </TraceDrawerComponents.DetailContainer>
  87. );
  88. }