span.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 type {Organization} from 'sentry/types';
  11. import useProjects from 'sentry/utils/useProjects';
  12. import {ProfileGroupProvider} from 'sentry/views/profiling/profileGroupProvider';
  13. import {ProfileContext, ProfilesProvider} from 'sentry/views/profiling/profilesProvider';
  14. import type {TraceTree, TraceTreeNode} from '../../traceTree';
  15. import {TraceDrawerComponents} from './styles';
  16. export function SpanNodeDetails({
  17. node,
  18. organization,
  19. scrollToNode,
  20. }: {
  21. node: TraceTreeNode<TraceTree.Span>;
  22. organization: Organization;
  23. scrollToNode: (node: TraceTreeNode<TraceTree.NodeValue>) => void;
  24. }) {
  25. const {projects} = useProjects();
  26. const {event, errors, performance_issues, 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. <div>
  41. <div>{t('span')}</div>
  42. <TraceDrawerComponents.TitleOp>
  43. {' '}
  44. {getSpanOperation(span)}
  45. </TraceDrawerComponents.TitleOp>
  46. </div>
  47. </TraceDrawerComponents.Title>
  48. <Button size="xs" onClick={_e => scrollToNode(node)}>
  49. {t('Show in view')}
  50. </Button>
  51. </TraceDrawerComponents.HeaderContainer>
  52. {event.projectSlug && (
  53. <ProfilesProvider
  54. orgSlug={organization.slug}
  55. projectSlug={event.projectSlug}
  56. profileId={profileId || ''}
  57. >
  58. <ProfileContext.Consumer>
  59. {profiles => (
  60. <ProfileGroupProvider
  61. type="flamechart"
  62. input={profiles?.type === 'resolved' ? profiles.data : null}
  63. traceID={profileId || ''}
  64. >
  65. <NewTraceDetailsSpanDetail
  66. errors={errors}
  67. performanceIssues={performance_issues}
  68. childTransactions={childTransaction ? [childTransaction] : []}
  69. event={event}
  70. openPanel="open"
  71. organization={organization}
  72. span={span}
  73. trace={parseTrace(event)}
  74. />
  75. </ProfileGroupProvider>
  76. )}
  77. </ProfileContext.Consumer>
  78. </ProfilesProvider>
  79. )}
  80. </TraceDrawerComponents.DetailContainer>
  81. );
  82. }