traceNotFound.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import Alert from 'sentry/components/alert';
  4. import Link from 'sentry/components/links/link';
  5. import LoadingError from 'sentry/components/loadingError';
  6. import LoadingIndicator from 'sentry/components/loadingIndicator';
  7. import {
  8. ErrorDot,
  9. ErrorLevel,
  10. ErrorMessageContent,
  11. ErrorTitle,
  12. } from 'sentry/components/performance/waterfall/rowDetails';
  13. import {t, tct} from 'sentry/locale';
  14. import space from 'sentry/styles/space';
  15. import {Organization} from 'sentry/types';
  16. import DiscoverQuery from 'sentry/utils/discover/discoverQuery';
  17. import EventView from 'sentry/utils/discover/eventView';
  18. import {TraceMeta} from 'sentry/utils/performance/quickTrace/types';
  19. interface TraceNotFoundProps {
  20. location: any;
  21. meta: TraceMeta | null;
  22. organization: Organization;
  23. traceEventView: EventView;
  24. traceSlug: string;
  25. }
  26. function TraceNotFound({
  27. meta,
  28. traceEventView,
  29. traceSlug,
  30. organization,
  31. location,
  32. }: TraceNotFoundProps) {
  33. const transactions = meta?.transactions ?? 0;
  34. const errors = meta?.errors ?? 0;
  35. if (transactions === 0 && errors > 0) {
  36. const errorsEventView = traceEventView.withColumns([
  37. {kind: 'field', field: 'project'},
  38. {kind: 'field', field: 'title'},
  39. {kind: 'field', field: 'issue.id'},
  40. {kind: 'field', field: 'level'},
  41. ]);
  42. errorsEventView.query = `trace:${traceSlug} !event.type:transaction `;
  43. return (
  44. <DiscoverQuery
  45. eventView={errorsEventView}
  46. orgSlug={organization.slug}
  47. location={location}
  48. referrer="api.trace-view.errors-view"
  49. useEvents
  50. >
  51. {({isLoading, tableData, error}) => {
  52. if (isLoading) {
  53. return <LoadingIndicator />;
  54. }
  55. if (error) {
  56. return (
  57. <Alert type="error" showIcon>
  58. <ErrorLabel>
  59. {tct(
  60. 'The trace cannot be shown when all events are errors. An error occurred when attempting to fetch these error events: [error]',
  61. {error: error.message}
  62. )}
  63. </ErrorLabel>
  64. </Alert>
  65. );
  66. }
  67. return (
  68. <Alert type="error" showIcon>
  69. <ErrorLabel>
  70. {t('The trace cannot be shown when all events are errors.')}
  71. </ErrorLabel>
  72. <ErrorMessageContent data-test-id="trace-view-errors">
  73. {tableData?.data.map(data => (
  74. <Fragment key={data.id}>
  75. <ErrorDot level={data.level as any} />
  76. <ErrorLevel>{data.level}</ErrorLevel>
  77. <ErrorTitle>
  78. <Link
  79. to={`/organizations/${organization.slug}/issues/${data['issue.id']}/events/${data.id}?referrer=performance-trace-not-found`}
  80. >
  81. {data.title}
  82. </Link>
  83. </ErrorTitle>
  84. </Fragment>
  85. ))}
  86. </ErrorMessageContent>
  87. </Alert>
  88. );
  89. }}
  90. </DiscoverQuery>
  91. );
  92. }
  93. return <LoadingError message={t('The trace you are looking for was not found.')} />;
  94. }
  95. const ErrorLabel = styled('div')`
  96. margin-bottom: ${space(1)};
  97. `;
  98. export default TraceNotFound;