traceWarnings.tsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {useEffect} from 'react';
  2. import * as Sentry from '@sentry/react';
  3. import Alert from 'sentry/components/alert';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import {t, tct} from 'sentry/locale';
  6. import useOrganization from 'sentry/utils/useOrganization';
  7. import {traceAnalytics} from 'sentry/views/performance/newTraceDetails/traceAnalytics';
  8. import {TraceType} from './traceType';
  9. type TraceWarningsProps = {
  10. type: TraceType;
  11. };
  12. export function TraceWarnings({type}: TraceWarningsProps) {
  13. const organization = useOrganization();
  14. useEffect(() => {
  15. traceAnalytics.trackTraceWarningType(type, organization);
  16. }, [type, organization]);
  17. switch (type) {
  18. case TraceType.NO_ROOT:
  19. return (
  20. <Alert type="info" showIcon>
  21. <ExternalLink href="https://docs.sentry.io/product/performance/trace-view/#orphan-traces-and-broken-subtraces">
  22. {t(
  23. 'A root transaction is missing. Transactions linked by a dashed line have been orphaned and cannot be directly linked to the root.'
  24. )}
  25. </ExternalLink>
  26. </Alert>
  27. );
  28. case TraceType.BROKEN_SUBTRACES:
  29. return (
  30. <Alert type="info" showIcon>
  31. <ExternalLink href="https://docs.sentry.io/product/performance/trace-view/#orphan-traces-and-broken-subtraces">
  32. {t(
  33. 'This trace has broken subtraces. Transactions linked by a dashed line have been orphaned and cannot be directly linked to the root.'
  34. )}
  35. </ExternalLink>
  36. </Alert>
  37. );
  38. // Multiple roots are an edge case in browser SDKs and should be handled by the SDK.
  39. // The user should not see a warning as they cannot do anything about it.
  40. case TraceType.BROWSER_MULTIPLE_ROOTS:
  41. return null;
  42. case TraceType.MULTIPLE_ROOTS:
  43. return (
  44. <Alert type="info" showIcon>
  45. <ExternalLink href="https://docs.sentry.io/product/sentry-basics/tracing/trace-view/#multiple-roots">
  46. {t('Multiple root transactions have been found with this trace ID.')}
  47. </ExternalLink>
  48. </Alert>
  49. );
  50. case TraceType.ONLY_ERRORS:
  51. return (
  52. <Alert type="info" showIcon>
  53. {tct(
  54. "The good news is we know these errors are related to each other. The bad news is that we can't tell you more than that. If you haven't already, [tracingLink: configure performance monitoring for your SDKs] to learn more about service interactions.",
  55. {
  56. tracingLink: (
  57. <ExternalLink href="https://docs.sentry.io/product/performance/getting-started/" />
  58. ),
  59. }
  60. )}
  61. </Alert>
  62. );
  63. case TraceType.ONE_ROOT:
  64. case TraceType.EMPTY_TRACE:
  65. return null;
  66. default:
  67. Sentry.captureMessage(`Unhandled trace type - ${type}`);
  68. return null;
  69. }
  70. }