traceErrorRow.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import type {Theme} from '@emotion/react';
  2. import {PlatformIcon} from 'platformicons';
  3. import {t} from 'sentry/locale';
  4. import {TraceIcons} from '../traceIcons';
  5. import type {TraceTree} from '../traceModels/traceTree';
  6. import type {TraceTreeNode} from '../traceModels/traceTreeNode';
  7. import {InvisibleTraceBar} from '../traceRow/traceBar';
  8. import {
  9. maybeFocusTraceRow,
  10. TraceRowConnectors,
  11. type TraceRowProps,
  12. } from '../traceRow/traceRow';
  13. const ERROR_LEVEL_LABELS: Record<keyof Theme['level'], string> = {
  14. sample: t('Sample'),
  15. info: t('Info'),
  16. warning: t('Warning'),
  17. // Hardcoded legacy color (orange400). We no longer use orange anywhere
  18. // else in the app (except for the chart palette). This needs to be harcoded
  19. // here because existing users may still associate orange with the "error" level.
  20. error: t('Error'),
  21. fatal: t('Fatal'),
  22. default: t('Default'),
  23. unknown: t('Unknown'),
  24. };
  25. export function TraceErrorRow(props: TraceRowProps<TraceTreeNode<TraceTree.TraceError>>) {
  26. return (
  27. <div
  28. key={props.index}
  29. ref={r =>
  30. props.tabIndex === 0
  31. ? maybeFocusTraceRow(r, props.node, props.previouslyFocusedNodeRef)
  32. : null
  33. }
  34. tabIndex={props.tabIndex}
  35. className={`TraceRow ${props.rowSearchClassName} ${props.node.maxIssueSeverity}`}
  36. onPointerDown={props.onRowClick}
  37. onKeyDown={props.onRowKeyDown}
  38. style={props.style}
  39. >
  40. <div
  41. className="TraceLeftColumn"
  42. ref={props.registerListColumnRef}
  43. onDoubleClick={props.onRowDoubleClick}
  44. >
  45. <div className="TraceLeftColumnInner" style={props.listColumnStyle}>
  46. <div className="TraceChildrenCountWrapper">
  47. <TraceRowConnectors node={props.node} manager={props.manager} />{' '}
  48. </div>
  49. <PlatformIcon
  50. platform={props.projects[props.node.value.project_slug] ?? 'default'}
  51. />
  52. <span className="TraceOperation">
  53. {ERROR_LEVEL_LABELS[props.node.value.level ?? 'error']}
  54. </span>
  55. <strong className="TraceEmDash"> — </strong>
  56. <span className="TraceDescription">
  57. {props.node.value.message ?? props.node.value.title}
  58. </span>
  59. </div>
  60. </div>
  61. <div
  62. ref={props.registerSpanColumnRef}
  63. className={props.spanColumnClassName}
  64. onDoubleClick={props.onRowDoubleClick}
  65. >
  66. <InvisibleTraceBar
  67. node_space={props.node.space}
  68. manager={props.manager}
  69. virtualizedIndex={props.virtualized_index}
  70. >
  71. {typeof props.node.value.timestamp === 'number' ? (
  72. <div className={`TraceIcon ${props.node.value.level}`}>
  73. <TraceIcons.Icon event={props.node.value} />
  74. </div>
  75. ) : null}
  76. </InvisibleTraceBar>
  77. </div>
  78. </div>
  79. );
  80. }