issueQuickTrace.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Location} from 'history';
  4. import ErrorBoundary from 'sentry/components/errorBoundary';
  5. import QuickTrace from 'sentry/components/quickTrace';
  6. import {space} from 'sentry/styles/space';
  7. import type {Organization} from 'sentry/types';
  8. import {Event} from 'sentry/types/event';
  9. import {defined} from 'sentry/utils';
  10. import TraceMetaQuery from 'sentry/utils/performance/quickTrace/traceMetaQuery';
  11. import {QuickTraceQueryChildrenProps} from 'sentry/utils/performance/quickTrace/types';
  12. import {getTraceTimeRangeFromEvent} from 'sentry/utils/performance/quickTrace/utils';
  13. import useRouteAnalyticsParams from 'sentry/utils/routeAnalytics/useRouteAnalyticsParams';
  14. import {TraceLink} from 'sentry/views/issueDetails/quickTrace/traceLink';
  15. type Props = {
  16. event: Event;
  17. location: Location;
  18. organization: Organization;
  19. quickTrace: undefined | QuickTraceQueryChildrenProps;
  20. };
  21. function IssueQuickTrace({event, location, organization, quickTrace}: Props) {
  22. const isTraceMissing =
  23. !quickTrace ||
  24. quickTrace.error ||
  25. ((!defined(quickTrace.trace) || quickTrace.trace.length === 0) &&
  26. (!quickTrace.orphanErrors || quickTrace.orphanErrors?.length === 0));
  27. const traceId = event.contexts?.trace?.trace_id ?? '';
  28. const {start, end} = getTraceTimeRangeFromEvent(event);
  29. useRouteAnalyticsParams({
  30. trace_status: isTraceMissing
  31. ? quickTrace?.type === 'missing'
  32. ? 'transaction missing'
  33. : 'trace missing'
  34. : 'success',
  35. });
  36. if (isTraceMissing) {
  37. return (
  38. <QuickTraceWrapper>
  39. <TraceLink
  40. quickTrace={quickTrace}
  41. event={event}
  42. traceMeta={null}
  43. source="issues"
  44. />
  45. </QuickTraceWrapper>
  46. );
  47. }
  48. return (
  49. <ErrorBoundary mini>
  50. <QuickTraceWrapper>
  51. <TraceMetaQuery
  52. location={location}
  53. orgSlug={organization.slug}
  54. traceId={traceId}
  55. start={start}
  56. end={end}
  57. >
  58. {metaResults => (
  59. <Fragment>
  60. <QuickTrace
  61. event={event}
  62. quickTrace={quickTrace}
  63. location={location}
  64. organization={organization}
  65. anchor="left"
  66. errorDest="issue"
  67. transactionDest="performance"
  68. />
  69. <TraceLink
  70. quickTrace={quickTrace}
  71. event={event}
  72. traceMeta={metaResults?.meta ?? null}
  73. source="issues"
  74. />
  75. </Fragment>
  76. )}
  77. </TraceMetaQuery>
  78. </QuickTraceWrapper>
  79. </ErrorBoundary>
  80. );
  81. }
  82. const QuickTraceWrapper = styled('div')`
  83. display: flex;
  84. align-items: center;
  85. gap: ${space(0.75)};
  86. flex-wrap: wrap;
  87. margin-top: ${space(0.75)};
  88. height: 20px;
  89. `;
  90. export default IssueQuickTrace;