missingInstrumentation.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import {useTheme} from '@emotion/react';
  2. import {TransactionToProfileButton} from 'sentry/components/profiling/transactionToProfileButton';
  3. import {IconSpan} from 'sentry/icons';
  4. import {t} from 'sentry/locale';
  5. import getDuration from 'sentry/utils/duration/getDuration';
  6. import useProjects from 'sentry/utils/useProjects';
  7. import {ProfilePreview} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/profiling/profilePreview';
  8. import type {TraceTreeNodeDetailsProps} from 'sentry/views/performance/newTraceDetails/traceDrawer/tabs/traceTreeNodeDetails';
  9. import {getTraceTabTitle} from 'sentry/views/performance/newTraceDetails/traceState/traceTabs';
  10. import {Row} from 'sentry/views/performance/traceDetails/styles';
  11. import {ProfileGroupProvider} from 'sentry/views/profiling/profileGroupProvider';
  12. import {ProfileContext, ProfilesProvider} from 'sentry/views/profiling/profilesProvider';
  13. import {
  14. makeTraceNodeBarColor,
  15. type MissingInstrumentationNode,
  16. } from '../../traceModels/traceTree';
  17. import {TraceDrawerComponents} from './styles';
  18. export function MissingInstrumentationNodeDetails({
  19. node,
  20. onParentClick,
  21. onTabScrollToNode,
  22. organization,
  23. }: TraceTreeNodeDetailsProps<MissingInstrumentationNode>) {
  24. const theme = useTheme();
  25. const {projects} = useProjects();
  26. const parentTransaction = node.parent_transaction;
  27. const event = node.previous.value.event || node.next.value.event || null;
  28. const project = projects.find(proj => proj.slug === event?.projectSlug);
  29. const profileId = event?.contexts?.profile?.profile_id ?? null;
  30. return (
  31. <TraceDrawerComponents.DetailContainer>
  32. <TraceDrawerComponents.HeaderContainer>
  33. <TraceDrawerComponents.Title>
  34. <TraceDrawerComponents.IconTitleWrapper>
  35. <TraceDrawerComponents.IconBorder
  36. backgroundColor={makeTraceNodeBarColor(theme, node)}
  37. >
  38. <IconSpan size="md" />
  39. </TraceDrawerComponents.IconBorder>
  40. <div style={{fontWeight: 'bold'}}>{t('Missing Instrumentation')}</div>
  41. </TraceDrawerComponents.IconTitleWrapper>
  42. </TraceDrawerComponents.Title>
  43. <TraceDrawerComponents.NodeActions
  44. organization={organization}
  45. node={node}
  46. onTabScrollToNode={onTabScrollToNode}
  47. />
  48. </TraceDrawerComponents.HeaderContainer>
  49. {event.projectSlug ? (
  50. <ProfilesProvider
  51. orgSlug={organization.slug}
  52. projectSlug={event.projectSlug}
  53. profileId={profileId || ''}
  54. >
  55. <ProfileContext.Consumer>
  56. {profiles => (
  57. <ProfileGroupProvider
  58. type="flamechart"
  59. input={profiles?.type === 'resolved' ? profiles.data : null}
  60. traceID={profileId || ''}
  61. >
  62. <ProfilePreview event={event} node={node} />
  63. </ProfileGroupProvider>
  64. )}
  65. </ProfileContext.Consumer>
  66. </ProfilesProvider>
  67. ) : null}
  68. <TraceDrawerComponents.Table className="table key-value">
  69. <tbody>
  70. {parentTransaction ? (
  71. <Row title="Parent Transaction">
  72. <td className="value">
  73. <a onClick={() => onParentClick(parentTransaction)}>
  74. {getTraceTabTitle(parentTransaction)}
  75. </a>
  76. </td>
  77. </Row>
  78. ) : null}
  79. <Row title={t('Duration')}>
  80. {getDuration(node.value.timestamp - node.value.start_timestamp, 2, true)}
  81. </Row>
  82. {profileId && project?.slug && (
  83. <Row
  84. title="Profile ID"
  85. extra={
  86. <TransactionToProfileButton
  87. size="xs"
  88. projectSlug={project.slug}
  89. event={event}
  90. >
  91. {t('View Profile')}
  92. </TransactionToProfileButton>
  93. }
  94. >
  95. {profileId}
  96. </Row>
  97. )}
  98. <Row title={t('Previous Span')}>
  99. {node.previous.value.op} - {node.previous.value.description}
  100. </Row>
  101. <Row title={t('Next Span')}>
  102. {node.next.value.op} - {node.next.value.description}
  103. </Row>
  104. </tbody>
  105. </TraceDrawerComponents.Table>
  106. </TraceDrawerComponents.DetailContainer>
  107. );
  108. }