traceWarnings.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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} 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/concepts/key-terms/tracing/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/concepts/key-terms/tracing/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/concepts/key-terms/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. case TraceType.ONE_ROOT:
  52. case TraceType.EMPTY_TRACE:
  53. return null;
  54. default:
  55. Sentry.captureMessage(`Unhandled trace type - ${type}`);
  56. return null;
  57. }
  58. }