traceSpanRow.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import {TraceIcons} from '../traceIcons';
  2. import type {TraceTree} from '../traceModels/traceTree';
  3. import type {TraceTreeNode} from '../traceModels/traceTreeNode';
  4. import {makeTraceNodeBarColor, TraceBar} from '../traceRow/traceBar';
  5. import {
  6. maybeFocusTraceRow,
  7. TRACE_COUNT_FORMATTER,
  8. TraceChildrenButton,
  9. TraceRowConnectors,
  10. type TraceRowProps,
  11. } from '../traceRow/traceRow';
  12. const NO_PROFILES = [];
  13. export function TraceSpanRow(props: TraceRowProps<TraceTreeNode<TraceTree.Span>>) {
  14. return (
  15. <div
  16. key={props.index}
  17. ref={r =>
  18. props.tabIndex === 0
  19. ? maybeFocusTraceRow(r, props.node, props.previouslyFocusedNodeRef)
  20. : null
  21. }
  22. tabIndex={props.tabIndex}
  23. className={`TraceRow ${props.rowSearchClassName} ${props.node.hasErrors ? props.node.maxIssueSeverity : ''}`}
  24. onPointerDown={props.onRowClick}
  25. onKeyDown={props.onRowKeyDown}
  26. style={props.style}
  27. >
  28. <div
  29. className="TraceLeftColumn"
  30. ref={props.registerListColumnRef}
  31. onDoubleClick={props.onRowDoubleClick}
  32. >
  33. <div className="TraceLeftColumnInner" style={props.listColumnStyle}>
  34. <div className={props.listColumnClassName}>
  35. <TraceRowConnectors node={props.node} manager={props.manager} />
  36. {props.node.children.length > 0 || props.node.canFetch ? (
  37. <TraceChildrenButton
  38. icon={
  39. props.node.canFetch ? (
  40. '+'
  41. ) : (
  42. <TraceIcons.Chevron direction={props.node.expanded ? 'up' : 'down'} />
  43. )
  44. }
  45. status={props.node.fetchStatus}
  46. expanded={props.node.expanded || props.node.zoomedIn}
  47. onDoubleClick={props.onExpandDoubleClick}
  48. onClick={e =>
  49. props.node.canFetch ? props.onZoomIn(e) : props.onExpand(e)
  50. }
  51. >
  52. {props.node.children.length > 0
  53. ? TRACE_COUNT_FORMATTER.format(props.node.children.length)
  54. : null}
  55. </TraceChildrenButton>
  56. ) : null}
  57. </div>
  58. <span className="TraceOperation">{props.node.value.op ?? '<unknown>'}</span>
  59. <strong className="TraceEmDash"> — </strong>
  60. <span className="TraceDescription" title={props.node.value.description}>
  61. {!props.node.value.description
  62. ? props.node.value.span_id ?? 'unknown'
  63. : props.node.value.description.length > 100
  64. ? props.node.value.description.slice(0, 100).trim() + '\u2026'
  65. : props.node.value.description}
  66. </span>
  67. </div>
  68. </div>
  69. <div
  70. ref={props.registerSpanColumnRef}
  71. className={props.spanColumnClassName}
  72. onDoubleClick={props.onRowDoubleClick}
  73. >
  74. <TraceBar
  75. node={props.node}
  76. virtualized_index={props.virtualized_index}
  77. manager={props.manager}
  78. color={makeTraceNodeBarColor(props.theme, props.node)}
  79. node_space={props.node.space}
  80. errors={props.node.errors}
  81. performance_issues={props.node.performance_issues}
  82. profiles={NO_PROFILES}
  83. />
  84. <button
  85. ref={props.registerSpanArrowRef}
  86. className="TraceArrow"
  87. onClick={props.onSpanArrowClick}
  88. >
  89. <TraceIcons.Chevron direction="left" />
  90. </button>
  91. </div>
  92. </div>
  93. );
  94. }