trace.tsx 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351
  1. import type React from 'react';
  2. import {Fragment, useCallback, useLayoutEffect, useMemo, useRef, useState} from 'react';
  3. import {type Theme, useTheme} from '@emotion/react';
  4. import styled from '@emotion/styled';
  5. import * as Sentry from '@sentry/react';
  6. import {PlatformIcon} from 'platformicons';
  7. import * as qs from 'query-string';
  8. import LoadingIndicator from 'sentry/components/loadingIndicator';
  9. import Placeholder from 'sentry/components/placeholder';
  10. import {t, tct} from 'sentry/locale';
  11. import {space} from 'sentry/styles/space';
  12. import type {Organization, PlatformKey, Project} from 'sentry/types';
  13. import type {
  14. TraceError,
  15. TracePerformanceIssue,
  16. } from 'sentry/utils/performance/quickTrace/types';
  17. import {clamp} from 'sentry/utils/profiling/colors/utils';
  18. import useApi from 'sentry/utils/useApi';
  19. import useOrganization from 'sentry/utils/useOrganization';
  20. import useProjects from 'sentry/utils/useProjects';
  21. import {formatTraceDuration} from 'sentry/views/performance/newTraceDetails/formatters';
  22. import {
  23. useVirtualizedList,
  24. type VirtualizedRow,
  25. } from 'sentry/views/performance/newTraceDetails/traceRenderers/traceVirtualizedList';
  26. import type {VirtualizedViewManager} from 'sentry/views/performance/newTraceDetails/traceRenderers/virtualizedViewManager';
  27. import type {
  28. TraceReducerAction,
  29. TraceReducerState,
  30. } from 'sentry/views/performance/newTraceDetails/traceState';
  31. import {
  32. getRovingIndexActionFromDOMEvent,
  33. type RovingTabIndexUserActions,
  34. } from 'sentry/views/performance/newTraceDetails/traceState/traceRovingTabIndex';
  35. import {
  36. makeTraceNodeBarColor,
  37. ParentAutogroupNode,
  38. TraceTree,
  39. type TraceTreeNode,
  40. } from './traceModels/traceTree';
  41. import {
  42. isAutogroupedNode,
  43. isMissingInstrumentationNode,
  44. isNoDataNode,
  45. isParentAutogroupedNode,
  46. isSpanNode,
  47. isTraceErrorNode,
  48. isTraceNode,
  49. isTransactionNode,
  50. } from './guards';
  51. import {TraceIcons} from './icons';
  52. function decodeScrollQueue(maybePath: unknown): TraceTree.NodePath[] | null {
  53. if (Array.isArray(maybePath)) {
  54. return maybePath;
  55. }
  56. if (typeof maybePath === 'string') {
  57. return [maybePath as TraceTree.NodePath];
  58. }
  59. return null;
  60. }
  61. const COUNT_FORMATTER = Intl.NumberFormat(undefined, {notation: 'compact'});
  62. const NO_ERRORS = new Set<TraceError>();
  63. const NO_PERFORMANCE_ISSUES = new Set<TracePerformanceIssue>();
  64. const NO_PROFILES = [];
  65. function computeNextIndexFromAction(
  66. current_index: number,
  67. action: RovingTabIndexUserActions,
  68. items: number
  69. ): number {
  70. switch (action) {
  71. case 'next':
  72. if (current_index === items) {
  73. return 0;
  74. }
  75. return current_index + 1;
  76. case 'previous':
  77. if (current_index === 0) {
  78. return items;
  79. }
  80. return current_index - 1;
  81. case 'last':
  82. return items;
  83. case 'first':
  84. return 0;
  85. default:
  86. throw new TypeError(`Invalid or not implemented reducer action - ${action}`);
  87. }
  88. }
  89. const RIGHT_COLUMN_EVEN_CLASSNAME = `TraceRightColumn`;
  90. const RIGHT_COLUMN_ODD_CLASSNAME = [RIGHT_COLUMN_EVEN_CLASSNAME, 'Odd'].join(' ');
  91. const CHILDREN_COUNT_WRAPPER_CLASSNAME = `TraceChildrenCountWrapper`;
  92. const CHILDREN_COUNT_WRAPPER_ORPHANED_CLASSNAME = [
  93. CHILDREN_COUNT_WRAPPER_CLASSNAME,
  94. 'Orphaned',
  95. ].join(' ');
  96. const ERROR_LEVEL_LABELS: Record<keyof Theme['level'], string> = {
  97. sample: t('Sample'),
  98. info: t('Info'),
  99. warning: t('Warning'),
  100. // Hardcoded legacy color (orange400). We no longer use orange anywhere
  101. // else in the app (except for the chart palette). This needs to be harcoded
  102. // here because existing users may still associate orange with the "error" level.
  103. error: t('Error'),
  104. fatal: t('Fatal'),
  105. default: t('Default'),
  106. unknown: t('Unknown'),
  107. };
  108. function maybeFocusRow(
  109. ref: HTMLDivElement | null,
  110. node: TraceTreeNode<TraceTree.NodeValue>,
  111. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>
  112. ) {
  113. if (!ref) return;
  114. if (node === previouslyFocusedNodeRef.current) return;
  115. previouslyFocusedNodeRef.current = node;
  116. ref.focus();
  117. }
  118. interface TraceProps {
  119. forceRerender: number;
  120. manager: VirtualizedViewManager;
  121. onRowClick: (
  122. node: TraceTreeNode<TraceTree.NodeValue>,
  123. event: React.MouseEvent<HTMLElement>,
  124. index: number
  125. ) => void;
  126. onTraceLoad: (
  127. trace: TraceTree,
  128. node: TraceTreeNode<TraceTree.NodeValue> | null,
  129. index: number | null
  130. ) => void;
  131. onTraceSearch: (
  132. query: string,
  133. node: TraceTreeNode<TraceTree.NodeValue>,
  134. behavior: 'track result' | 'persist'
  135. ) => void;
  136. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>;
  137. rerender: () => void;
  138. scrollQueueRef: React.MutableRefObject<{
  139. eventId?: string;
  140. path?: TraceTree.NodePath[];
  141. } | null>;
  142. trace: TraceTree;
  143. trace_dispatch: React.Dispatch<TraceReducerAction>;
  144. trace_id: string;
  145. trace_state: TraceReducerState;
  146. }
  147. export function Trace({
  148. trace,
  149. trace_id,
  150. onRowClick,
  151. manager,
  152. scrollQueueRef,
  153. previouslyFocusedNodeRef,
  154. onTraceSearch,
  155. onTraceLoad,
  156. rerender,
  157. trace_state,
  158. trace_dispatch,
  159. forceRerender,
  160. }: TraceProps) {
  161. const theme = useTheme();
  162. const api = useApi();
  163. const {projects} = useProjects();
  164. const organization = useOrganization();
  165. const containerRef = useRef<HTMLDivElement | null>(null);
  166. const rerenderRef = useRef<TraceProps['rerender']>(rerender);
  167. rerenderRef.current = rerender;
  168. const treePromiseStatusRef =
  169. useRef<Map<TraceTreeNode<TraceTree.NodeValue>, 'loading' | 'error' | 'success'>>();
  170. if (!treePromiseStatusRef.current) {
  171. treePromiseStatusRef.current = new Map();
  172. }
  173. const treeRef = useRef<TraceTree>(trace);
  174. treeRef.current = trace;
  175. const traceStateRef = useRef<TraceReducerState>(trace_state);
  176. traceStateRef.current = trace_state;
  177. if (
  178. trace.root.space &&
  179. (trace.root.space[0] !== manager.to_origin ||
  180. trace.root.space[1] !== manager.trace_space.width)
  181. ) {
  182. manager.initializeTraceSpace([trace.root.space[0], 0, trace.root.space[1], 1]);
  183. const maybeQueue = decodeScrollQueue(qs.parse(location.search).node);
  184. const maybeEventId = qs.parse(location.search)?.eventId;
  185. if (maybeQueue || maybeEventId) {
  186. scrollQueueRef.current = {
  187. eventId: maybeEventId as string,
  188. path: maybeQueue as TraceTreeNode<TraceTree.NodeValue>['path'],
  189. };
  190. }
  191. }
  192. const loadedRef = useRef(false);
  193. useLayoutEffect(() => {
  194. if (loadedRef.current) {
  195. return;
  196. }
  197. if (trace.type !== 'trace' || !manager) {
  198. return;
  199. }
  200. loadedRef.current = true;
  201. if (!scrollQueueRef.current) {
  202. onTraceLoad(trace, null, null);
  203. return;
  204. }
  205. // Node path has higher specificity than eventId
  206. const promise = scrollQueueRef.current?.path
  207. ? TraceTree.ExpandToPath(trace, scrollQueueRef.current.path, rerenderRef.current, {
  208. api,
  209. organization,
  210. })
  211. : scrollQueueRef.current.eventId
  212. ? TraceTree.ExpandToEventID(
  213. scrollQueueRef?.current?.eventId,
  214. trace,
  215. rerenderRef.current,
  216. {
  217. api,
  218. organization,
  219. }
  220. )
  221. : Promise.resolve(null);
  222. promise
  223. .then(maybeNode => {
  224. onTraceLoad(trace, maybeNode?.node ?? null, maybeNode?.index ?? null);
  225. if (!maybeNode) {
  226. Sentry.captureMessage('Failed to find and scroll to node in tree');
  227. return;
  228. }
  229. })
  230. .finally(() => {
  231. // Important to set scrollQueueRef.current to null and trigger a rerender
  232. // after the promise resolves as we show a loading state during scroll,
  233. // else the screen could jump around while we fetch span data
  234. scrollQueueRef.current = null;
  235. rerenderRef.current();
  236. });
  237. }, [
  238. api,
  239. trace,
  240. trace_id,
  241. manager,
  242. onTraceLoad,
  243. trace_dispatch,
  244. scrollQueueRef,
  245. organization,
  246. ]);
  247. const onNodeZoomIn = useCallback(
  248. (
  249. event: React.MouseEvent<Element> | React.KeyboardEvent<Element>,
  250. node: TraceTreeNode<TraceTree.NodeValue>,
  251. value: boolean
  252. ) => {
  253. if (!isTransactionNode(node) && !isSpanNode(node)) {
  254. throw new TypeError('Node must be a transaction or span');
  255. }
  256. event.stopPropagation();
  257. rerenderRef.current();
  258. treeRef.current
  259. .zoomIn(node, value, {
  260. api,
  261. organization,
  262. })
  263. .then(() => {
  264. rerenderRef.current();
  265. // If a query exists, we want to reapply the search after zooming in
  266. // so that new nodes are also highlighted if they match a query
  267. if (traceStateRef.current.search.query) {
  268. onTraceSearch(traceStateRef.current.search.query, node, 'persist');
  269. }
  270. treePromiseStatusRef.current!.set(node, 'success');
  271. })
  272. .catch(_e => {
  273. treePromiseStatusRef.current!.set(node, 'error');
  274. });
  275. },
  276. [api, organization, onTraceSearch]
  277. );
  278. const onNodeExpand = useCallback(
  279. (
  280. event: React.MouseEvent<Element> | React.KeyboardEvent<Element>,
  281. node: TraceTreeNode<TraceTree.NodeValue>,
  282. value: boolean
  283. ) => {
  284. event.stopPropagation();
  285. treeRef.current.expand(node, value);
  286. rerenderRef.current();
  287. if (traceStateRef.current.search.query) {
  288. // If a query exists, we want to reapply the search after expanding
  289. // so that new nodes are also highlighted if they match a query
  290. onTraceSearch(traceStateRef.current.search.query, node, 'persist');
  291. }
  292. },
  293. [onTraceSearch]
  294. );
  295. const onRowKeyDown = useCallback(
  296. (
  297. event: React.KeyboardEvent,
  298. index: number,
  299. node: TraceTreeNode<TraceTree.NodeValue>
  300. ) => {
  301. if (!manager.list) {
  302. return;
  303. }
  304. const action = getRovingIndexActionFromDOMEvent(event);
  305. if (action) {
  306. event.preventDefault();
  307. const nextIndex = computeNextIndexFromAction(
  308. index,
  309. action,
  310. treeRef.current.list.length - 1
  311. );
  312. trace_dispatch({
  313. type: 'set roving index',
  314. index: nextIndex,
  315. node: treeRef.current.list[nextIndex],
  316. action_source: 'keyboard',
  317. });
  318. }
  319. if (event.key === 'ArrowLeft') {
  320. if (node.zoomedIn) onNodeZoomIn(event, node, false);
  321. else if (node.expanded) onNodeExpand(event, node, false);
  322. } else if (event.key === 'ArrowRight') {
  323. if (!node.expanded) onNodeExpand(event, node, true);
  324. else if (node.expanded && node.canFetch) onNodeZoomIn(event, node, true);
  325. }
  326. },
  327. [manager, onNodeExpand, onNodeZoomIn, trace_dispatch]
  328. );
  329. const projectLookup: Record<string, PlatformKey | undefined> = useMemo(() => {
  330. return projects.reduce<Record<Project['slug'], Project['platform']>>(
  331. (acc, project) => {
  332. acc[project.slug] = project.platform;
  333. return acc;
  334. },
  335. {}
  336. );
  337. }, [projects]);
  338. const renderLoadingRow = useCallback(
  339. (n: VirtualizedRow) => {
  340. return (
  341. <RenderPlaceholderRow
  342. key={n.key}
  343. index={n.index}
  344. style={n.style}
  345. node={n.item}
  346. theme={theme}
  347. manager={manager}
  348. />
  349. );
  350. },
  351. [manager, theme]
  352. );
  353. const renderVirtualizedRow = useCallback(
  354. (n: VirtualizedRow) => {
  355. return (
  356. <RenderRow
  357. key={n.key}
  358. index={n.index}
  359. organization={organization}
  360. previouslyFocusedNodeRef={previouslyFocusedNodeRef}
  361. tabIndex={trace_state.rovingTabIndex.node === n.item ? 0 : -1}
  362. isSearchResult={trace_state.search.resultsLookup.has(n.item)}
  363. searchResultsIteratorIndex={trace_state.search.resultIndex}
  364. style={n.style}
  365. trace_id={trace_id}
  366. projects={projectLookup}
  367. node={n.item}
  368. manager={manager}
  369. theme={theme}
  370. onExpand={onNodeExpand}
  371. onZoomIn={onNodeZoomIn}
  372. onRowClick={onRowClick}
  373. onRowKeyDown={onRowKeyDown}
  374. />
  375. );
  376. },
  377. // we add forceRerender as a "unnecessary" dependency to trigger the virtualized list rerender
  378. // eslint-disable-next-line react-hooks/exhaustive-deps
  379. [
  380. onNodeExpand,
  381. onNodeZoomIn,
  382. manager,
  383. scrollQueueRef,
  384. previouslyFocusedNodeRef,
  385. onRowKeyDown,
  386. onRowClick,
  387. organization,
  388. projectLookup,
  389. trace_state.rovingTabIndex.node,
  390. trace_state.search.resultIteratorIndex,
  391. trace_state.search.resultsLookup,
  392. trace_state.search.resultIndex,
  393. theme,
  394. trace_id,
  395. trace.type,
  396. forceRerender,
  397. ]
  398. );
  399. const render = useMemo(() => {
  400. return trace.type !== 'trace' || scrollQueueRef.current
  401. ? r => renderLoadingRow(r)
  402. : r => renderVirtualizedRow(r);
  403. }, [renderLoadingRow, renderVirtualizedRow, trace.type, scrollQueueRef]);
  404. const [scrollContainer, setScrollContainer] = useState<HTMLElement | null>(null);
  405. const virtualizedList = useVirtualizedList({
  406. manager,
  407. items: trace.list,
  408. container: scrollContainer,
  409. render: render,
  410. });
  411. return (
  412. <TraceStylingWrapper
  413. ref={r => {
  414. containerRef.current = r;
  415. manager.registerContainerRef(r);
  416. }}
  417. className={`${trace.indicators.length > 0 ? 'WithIndicators' : ''} ${trace.type !== 'trace' || scrollQueueRef.current ? 'Loading' : ''}`}
  418. >
  419. <div
  420. className="TraceScrollbarContainer"
  421. ref={r => manager.registerHorizontalScrollBarContainerRef(r)}
  422. >
  423. <div className="TraceScrollbarScroller" />
  424. </div>
  425. <div className="TraceDivider" ref={r => manager.registerDividerRef(r)} />
  426. <div
  427. className="TraceIndicatorContainer"
  428. ref={r => manager.registerIndicatorContainerRef(r)}
  429. >
  430. {trace.indicators.length > 0
  431. ? trace.indicators.map((indicator, i) => {
  432. return (
  433. <div
  434. key={i}
  435. ref={r => manager.registerIndicatorRef(r, i, indicator)}
  436. className={`TraceIndicator ${indicator.poor ? 'Errored' : ''}`}
  437. >
  438. <div className="TraceIndicatorLabel">{indicator.label}</div>
  439. <div className="TraceIndicatorLine" />
  440. </div>
  441. );
  442. })
  443. : null}
  444. {manager.interval_bars.map((_, i) => {
  445. const indicatorTimestamp = manager.intervals[i] ?? 0;
  446. const timestamp = manager.to_origin + indicatorTimestamp;
  447. if (trace.type !== 'trace') {
  448. return null;
  449. }
  450. return (
  451. <div
  452. key={i}
  453. ref={r => manager.registerTimelineIndicatorRef(r, i)}
  454. className="TraceIndicator Timeline"
  455. style={{
  456. transform: `translate(${manager.computeTransformXFromTimestamp(timestamp)}px, 0)`,
  457. }}
  458. >
  459. <div className="TraceIndicatorLabel">
  460. {indicatorTimestamp > 0
  461. ? formatTraceDuration(manager.trace_view.x + indicatorTimestamp)
  462. : '0s'}
  463. </div>
  464. <div className="TraceIndicatorLine" />
  465. </div>
  466. );
  467. })}
  468. </div>
  469. <div
  470. ref={r => setScrollContainer(r)}
  471. data-test-id="trace-virtualized-list-scroll-container"
  472. >
  473. <div data-test-id="trace-virtualized-list">{virtualizedList.rendered}</div>
  474. <div className="TraceRow Hidden">
  475. <div
  476. className="TraceLeftColumn"
  477. ref={r => manager.registerGhostRowRef('list', r)}
  478. />
  479. <div
  480. className="TraceRightColumn"
  481. ref={r => manager.registerGhostRowRef('span_list', r)}
  482. />
  483. </div>
  484. </div>
  485. </TraceStylingWrapper>
  486. );
  487. }
  488. function RenderRow(props: {
  489. index: number;
  490. isSearchResult: boolean;
  491. manager: VirtualizedViewManager;
  492. node: TraceTreeNode<TraceTree.NodeValue>;
  493. onExpand: (
  494. event: React.MouseEvent<Element>,
  495. node: TraceTreeNode<TraceTree.NodeValue>,
  496. value: boolean
  497. ) => void;
  498. onRowClick: (
  499. node: TraceTreeNode<TraceTree.NodeValue>,
  500. event: React.MouseEvent<HTMLElement>,
  501. index: number
  502. ) => void;
  503. onRowKeyDown: (
  504. event: React.KeyboardEvent,
  505. index: number,
  506. node: TraceTreeNode<TraceTree.NodeValue>
  507. ) => void;
  508. onZoomIn: (
  509. event: React.MouseEvent<Element>,
  510. node: TraceTreeNode<TraceTree.NodeValue>,
  511. value: boolean
  512. ) => void;
  513. organization: Organization;
  514. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>;
  515. projects: Record<Project['slug'], Project['platform']>;
  516. searchResultsIteratorIndex: number | null;
  517. style: React.CSSProperties;
  518. tabIndex: number;
  519. theme: Theme;
  520. trace_id: string;
  521. }) {
  522. const virtualized_index = props.index - props.manager.start_virtualized_index;
  523. const rowSearchClassName = `${props.isSearchResult ? 'SearchResult' : ''} ${props.searchResultsIteratorIndex === props.index ? 'Highlight' : ''}`;
  524. if (isAutogroupedNode(props.node)) {
  525. return (
  526. <div
  527. key={props.index}
  528. ref={r =>
  529. props.tabIndex === 0
  530. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  531. : null
  532. }
  533. tabIndex={props.tabIndex}
  534. className={`Autogrouped TraceRow ${rowSearchClassName} ${props.node.has_errors ? props.node.max_severity : ''}`}
  535. onClick={e => props.onRowClick(props.node, e, props.index)}
  536. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  537. style={{
  538. top: props.style.top,
  539. height: props.style.height,
  540. }}
  541. >
  542. <div
  543. className="TraceLeftColumn"
  544. ref={r =>
  545. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  546. }
  547. >
  548. <div
  549. className={`TraceLeftColumnInner`}
  550. style={{
  551. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  552. }}
  553. >
  554. <div className="TraceChildrenCountWrapper">
  555. <Connectors node={props.node} manager={props.manager} />
  556. <ChildrenButton
  557. icon={
  558. <TraceIcons.Chevron direction={props.node.expanded ? 'up' : 'down'} />
  559. }
  560. status={props.node.fetchStatus}
  561. expanded={!props.node.expanded}
  562. onClick={e => props.onExpand(e, props.node, !props.node.expanded)}
  563. >
  564. {COUNT_FORMATTER.format(props.node.groupCount)}
  565. </ChildrenButton>
  566. </div>
  567. <span className="TraceOperation">{t('Autogrouped')}</span>
  568. <strong className="TraceEmDash"> — </strong>
  569. <span className="TraceDescription">{props.node.value.autogrouped_by.op}</span>
  570. </div>
  571. </div>
  572. <div
  573. className={
  574. props.index % 2 === 1
  575. ? RIGHT_COLUMN_ODD_CLASSNAME
  576. : RIGHT_COLUMN_EVEN_CLASSNAME
  577. }
  578. ref={r =>
  579. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  580. }
  581. onDoubleClick={e => {
  582. e.stopPropagation();
  583. props.manager.onZoomIntoSpace(props.node.space!);
  584. }}
  585. >
  586. <AutogroupedTraceBar
  587. virtualized_index={virtualized_index}
  588. manager={props.manager}
  589. color={makeTraceNodeBarColor(props.theme, props.node)}
  590. entire_space={props.node.space}
  591. node_spaces={props.node.autogroupedSegments}
  592. errors={props.node.errors}
  593. performance_issues={props.node.performance_issues}
  594. profiles={props.node.profiles}
  595. />
  596. <button
  597. ref={ref =>
  598. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  599. }
  600. className="TraceArrow"
  601. onClick={_e => {
  602. props.manager.onBringRowIntoView(props.node.space!);
  603. }}
  604. >
  605. <TraceIcons.Chevron direction="left" />
  606. </button>
  607. </div>
  608. </div>
  609. );
  610. }
  611. if (isTransactionNode(props.node)) {
  612. return (
  613. <div
  614. key={props.index}
  615. ref={r =>
  616. props.tabIndex === 0
  617. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  618. : null
  619. }
  620. tabIndex={props.tabIndex}
  621. className={`TraceRow ${rowSearchClassName} ${props.node.has_errors ? props.node.max_severity : ''}`}
  622. onClick={e => props.onRowClick(props.node, e, props.index)}
  623. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  624. style={{
  625. top: props.style.top,
  626. height: props.style.height,
  627. }}
  628. >
  629. <div
  630. className="TraceLeftColumn"
  631. ref={r =>
  632. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  633. }
  634. >
  635. <div
  636. className={`TraceLeftColumnInner`}
  637. style={{
  638. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  639. }}
  640. >
  641. <div
  642. className={
  643. props.node.isOrphaned
  644. ? CHILDREN_COUNT_WRAPPER_ORPHANED_CLASSNAME
  645. : CHILDREN_COUNT_WRAPPER_CLASSNAME
  646. }
  647. >
  648. <Connectors node={props.node} manager={props.manager} />
  649. {props.node.children.length > 0 || props.node.canFetch ? (
  650. <ChildrenButton
  651. icon={
  652. props.node.canFetch && props.node.fetchStatus === 'idle' ? (
  653. '+'
  654. ) : props.node.canFetch && props.node.zoomedIn ? (
  655. <TraceIcons.Chevron direction="down" />
  656. ) : (
  657. '+'
  658. )
  659. }
  660. status={props.node.fetchStatus}
  661. expanded={props.node.expanded || props.node.zoomedIn}
  662. onClick={e => {
  663. props.node.canFetch
  664. ? props.onZoomIn(e, props.node, !props.node.zoomedIn)
  665. : props.onExpand(e, props.node, !props.node.expanded);
  666. }}
  667. >
  668. {props.node.children.length > 0
  669. ? COUNT_FORMATTER.format(props.node.children.length)
  670. : null}
  671. </ChildrenButton>
  672. ) : null}
  673. </div>
  674. <PlatformIcon
  675. platform={props.projects[props.node.value.project_slug] ?? 'default'}
  676. />
  677. <span className="TraceOperation">{props.node.value['transaction.op']}</span>
  678. <strong className="TraceEmDash"> — </strong>
  679. <span>{props.node.value.transaction}</span>
  680. </div>
  681. </div>
  682. <div
  683. ref={r =>
  684. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  685. }
  686. className={
  687. props.index % 2 === 1
  688. ? RIGHT_COLUMN_ODD_CLASSNAME
  689. : RIGHT_COLUMN_EVEN_CLASSNAME
  690. }
  691. onDoubleClick={e => {
  692. e.stopPropagation();
  693. props.manager.onZoomIntoSpace(props.node.space!);
  694. }}
  695. >
  696. <TraceBar
  697. virtualized_index={virtualized_index}
  698. manager={props.manager}
  699. color={makeTraceNodeBarColor(props.theme, props.node)}
  700. node_space={props.node.space}
  701. errors={props.node.errors}
  702. performance_issues={props.node.performance_issues}
  703. profiles={props.node.profiles}
  704. />
  705. <button
  706. ref={ref =>
  707. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  708. }
  709. className="TraceArrow"
  710. onClick={_e => {
  711. props.manager.onBringRowIntoView(props.node.space!);
  712. }}
  713. >
  714. <TraceIcons.Chevron direction="left" />
  715. </button>
  716. </div>
  717. </div>
  718. );
  719. }
  720. if (isSpanNode(props.node)) {
  721. return (
  722. <div
  723. key={props.index}
  724. ref={r =>
  725. props.tabIndex === 0
  726. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  727. : null
  728. }
  729. tabIndex={props.tabIndex}
  730. className={`TraceRow ${rowSearchClassName} ${props.node.has_errors ? props.node.max_severity : ''}`}
  731. onClick={e => props.onRowClick(props.node, e, props.index)}
  732. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  733. style={{
  734. top: props.style.top,
  735. height: props.style.height,
  736. }}
  737. >
  738. <div
  739. className="TraceLeftColumn"
  740. ref={r =>
  741. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  742. }
  743. >
  744. <div
  745. className={`TraceLeftColumnInner`}
  746. style={{
  747. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  748. }}
  749. >
  750. <div
  751. className={
  752. props.node.isOrphaned
  753. ? CHILDREN_COUNT_WRAPPER_ORPHANED_CLASSNAME
  754. : CHILDREN_COUNT_WRAPPER_CLASSNAME
  755. }
  756. >
  757. <Connectors node={props.node} manager={props.manager} />
  758. {props.node.children.length > 0 || props.node.canFetch ? (
  759. <ChildrenButton
  760. icon={
  761. props.node.canFetch ? (
  762. '+'
  763. ) : (
  764. <TraceIcons.Chevron
  765. direction={props.node.expanded ? 'up' : 'down'}
  766. />
  767. )
  768. }
  769. status={props.node.fetchStatus}
  770. expanded={props.node.expanded || props.node.zoomedIn}
  771. onClick={e =>
  772. props.node.canFetch
  773. ? props.onZoomIn(e, props.node, !props.node.zoomedIn)
  774. : props.onExpand(e, props.node, !props.node.expanded)
  775. }
  776. >
  777. {props.node.children.length > 0
  778. ? COUNT_FORMATTER.format(props.node.children.length)
  779. : null}
  780. </ChildrenButton>
  781. ) : null}
  782. </div>
  783. <span className="TraceOperation">{props.node.value.op ?? '<unknown>'}</span>
  784. <strong className="TraceEmDash"> — </strong>
  785. <span className="TraceDescription" title={props.node.value.description}>
  786. {!props.node.value.description
  787. ? props.node.value.span_id ?? 'unknown'
  788. : props.node.value.description.length > 100
  789. ? props.node.value.description.slice(0, 100).trim() + '\u2026'
  790. : props.node.value.description}
  791. </span>
  792. </div>
  793. </div>
  794. <div
  795. ref={r =>
  796. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  797. }
  798. className={
  799. props.index % 2 === 1
  800. ? RIGHT_COLUMN_ODD_CLASSNAME
  801. : RIGHT_COLUMN_EVEN_CLASSNAME
  802. }
  803. onDoubleClick={e => {
  804. e.stopPropagation();
  805. props.manager.onZoomIntoSpace(props.node.space!);
  806. }}
  807. >
  808. <TraceBar
  809. virtualized_index={virtualized_index}
  810. manager={props.manager}
  811. color={makeTraceNodeBarColor(props.theme, props.node)}
  812. node_space={props.node.space}
  813. errors={props.node.errors}
  814. performance_issues={props.node.performance_issues}
  815. profiles={NO_PROFILES}
  816. />
  817. <button
  818. ref={ref =>
  819. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  820. }
  821. className="TraceArrow"
  822. onClick={_e => {
  823. props.manager.onBringRowIntoView(props.node.space!);
  824. }}
  825. >
  826. <TraceIcons.Chevron direction="left" />
  827. </button>
  828. </div>
  829. </div>
  830. );
  831. }
  832. if (isMissingInstrumentationNode(props.node)) {
  833. return (
  834. <div
  835. key={props.index}
  836. ref={r =>
  837. props.tabIndex === 0
  838. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  839. : null
  840. }
  841. tabIndex={props.tabIndex}
  842. className={`TraceRow ${rowSearchClassName}`}
  843. onClick={e => props.onRowClick(props.node, e, props.index)}
  844. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  845. style={{
  846. top: props.style.top,
  847. height: props.style.height,
  848. }}
  849. >
  850. <div
  851. className="TraceLeftColumn"
  852. ref={r =>
  853. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  854. }
  855. >
  856. <div
  857. className="TraceLeftColumnInner"
  858. style={{
  859. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  860. }}
  861. >
  862. <div className="TraceChildrenCountWrapper">
  863. <Connectors node={props.node} manager={props.manager} />
  864. </div>
  865. <span className="TraceOperation">{t('Missing instrumentation')}</span>
  866. </div>
  867. </div>
  868. <div
  869. ref={r =>
  870. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  871. }
  872. className={
  873. props.index % 2 === 1
  874. ? RIGHT_COLUMN_ODD_CLASSNAME
  875. : RIGHT_COLUMN_EVEN_CLASSNAME
  876. }
  877. onDoubleClick={e => {
  878. e.stopPropagation();
  879. props.manager.onZoomIntoSpace(props.node.space!);
  880. }}
  881. >
  882. <TraceBar
  883. virtualized_index={virtualized_index}
  884. manager={props.manager}
  885. color={makeTraceNodeBarColor(props.theme, props.node)}
  886. node_space={props.node.space}
  887. performance_issues={NO_PERFORMANCE_ISSUES}
  888. profiles={NO_PROFILES}
  889. errors={NO_ERRORS}
  890. />
  891. <button
  892. ref={ref =>
  893. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  894. }
  895. className="TraceArrow"
  896. onClick={_e => {
  897. props.manager.onBringRowIntoView(props.node.space!);
  898. }}
  899. >
  900. <TraceIcons.Chevron direction="left" />
  901. </button>
  902. </div>
  903. </div>
  904. );
  905. }
  906. if (isTraceNode(props.node)) {
  907. return (
  908. <div
  909. key={props.index}
  910. ref={r =>
  911. props.tabIndex === 0
  912. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  913. : null
  914. }
  915. tabIndex={props.tabIndex}
  916. className={`TraceRow ${rowSearchClassName} ${props.node.has_errors ? props.node.max_severity : ''}`}
  917. onClick={e => props.onRowClick(props.node, e, props.index)}
  918. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  919. style={{
  920. top: props.style.top,
  921. height: props.style.height,
  922. }}
  923. >
  924. <div
  925. className="TraceLeftColumn"
  926. ref={r =>
  927. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  928. }
  929. >
  930. <div
  931. className="TraceLeftColumnInner"
  932. style={{
  933. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  934. }}
  935. >
  936. {' '}
  937. <div className="TraceChildrenCountWrapper Root">
  938. <Connectors node={props.node} manager={props.manager} />
  939. {props.node.children.length > 0 || props.node.canFetch ? (
  940. <ChildrenButton icon={''} status={'idle'} expanded onClick={() => void 0}>
  941. {props.node.children.length > 0
  942. ? COUNT_FORMATTER.format(props.node.children.length)
  943. : null}
  944. </ChildrenButton>
  945. ) : null}
  946. </div>
  947. <span className="TraceOperation">{t('Trace')}</span>
  948. <strong className="TraceEmDash"> — </strong>
  949. <span className="TraceDescription">{props.trace_id}</span>
  950. </div>
  951. </div>
  952. <div
  953. ref={r =>
  954. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  955. }
  956. className={
  957. props.index % 2 === 1
  958. ? RIGHT_COLUMN_ODD_CLASSNAME
  959. : RIGHT_COLUMN_EVEN_CLASSNAME
  960. }
  961. onDoubleClick={e => {
  962. e.stopPropagation();
  963. props.manager.onZoomIntoSpace(props.node.space!);
  964. }}
  965. >
  966. <TraceBar
  967. virtualized_index={virtualized_index}
  968. manager={props.manager}
  969. color={makeTraceNodeBarColor(props.theme, props.node)}
  970. node_space={props.node.space}
  971. errors={NO_ERRORS}
  972. performance_issues={NO_PERFORMANCE_ISSUES}
  973. profiles={NO_PROFILES}
  974. />
  975. <button
  976. ref={ref =>
  977. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  978. }
  979. className="TraceArrow"
  980. onClick={_e => {
  981. props.manager.onBringRowIntoView(props.node.space!);
  982. }}
  983. >
  984. <TraceIcons.Chevron direction="left" />
  985. </button>
  986. </div>
  987. </div>
  988. );
  989. }
  990. if (isTraceErrorNode(props.node)) {
  991. return (
  992. <div
  993. key={props.index}
  994. ref={r =>
  995. props.tabIndex === 0
  996. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  997. : null
  998. }
  999. tabIndex={props.tabIndex}
  1000. className={`TraceRow ${rowSearchClassName} ${props.node.max_severity}`}
  1001. onClick={e => props.onRowClick(props.node, e, props.index)}
  1002. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  1003. style={{
  1004. top: props.style.top,
  1005. height: props.style.height,
  1006. }}
  1007. >
  1008. <div
  1009. className="TraceLeftColumn"
  1010. ref={r =>
  1011. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  1012. }
  1013. >
  1014. <div
  1015. className="TraceLeftColumnInner"
  1016. style={{
  1017. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  1018. }}
  1019. >
  1020. <div className="TraceChildrenCountWrapper">
  1021. <Connectors node={props.node} manager={props.manager} />{' '}
  1022. </div>
  1023. <PlatformIcon
  1024. platform={props.projects[props.node.value.project_slug] ?? 'default'}
  1025. />
  1026. <span className="TraceOperation">
  1027. {ERROR_LEVEL_LABELS[props.node.value.level ?? 'error']}
  1028. </span>
  1029. <strong className="TraceEmDash"> — </strong>
  1030. <span className="TraceDescription">{props.node.value.title}</span>
  1031. </div>
  1032. </div>
  1033. <div
  1034. ref={r =>
  1035. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  1036. }
  1037. className={
  1038. props.index % 2 === 1
  1039. ? RIGHT_COLUMN_ODD_CLASSNAME
  1040. : RIGHT_COLUMN_EVEN_CLASSNAME
  1041. }
  1042. onDoubleClick={e => {
  1043. e.stopPropagation();
  1044. props.manager.onZoomIntoSpace(props.node.space!);
  1045. }}
  1046. >
  1047. <InvisibleTraceBar
  1048. node_space={props.node.space}
  1049. manager={props.manager}
  1050. virtualizedIndex={virtualized_index}
  1051. >
  1052. {typeof props.node.value.timestamp === 'number' ? (
  1053. <div className={`TraceIcon ${props.node.value.level}`}>
  1054. <TraceIcons.Icon event={props.node.value} />
  1055. </div>
  1056. ) : null}
  1057. </InvisibleTraceBar>
  1058. </div>
  1059. </div>
  1060. );
  1061. }
  1062. if (isNoDataNode(props.node)) {
  1063. return (
  1064. <div
  1065. key={props.index}
  1066. ref={r =>
  1067. props.tabIndex === 0
  1068. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  1069. : null
  1070. }
  1071. tabIndex={props.tabIndex}
  1072. className={`TraceRow ${rowSearchClassName}`}
  1073. onClick={e => props.onRowClick(props.node, e, props.index)}
  1074. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  1075. style={{
  1076. top: props.style.top,
  1077. height: props.style.height,
  1078. }}
  1079. >
  1080. <div
  1081. className="TraceLeftColumn"
  1082. ref={r =>
  1083. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  1084. }
  1085. >
  1086. <div
  1087. className="TraceLeftColumnInner"
  1088. style={{
  1089. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  1090. }}
  1091. >
  1092. <div className="TraceChildrenCountWrapper">
  1093. <Connectors node={props.node} manager={props.manager} />
  1094. </div>
  1095. <span className="TraceOperation">{t('Empty')}</span>{' '}
  1096. <strong className="TraceEmDash"> — </strong>
  1097. <span className="TraceDescription">
  1098. {tct('[type] did not report any span data', {
  1099. type: props.node.parent
  1100. ? isTransactionNode(props.node.parent)
  1101. ? 'Transaction'
  1102. : isSpanNode(props.node.parent)
  1103. ? 'Span'
  1104. : ''
  1105. : '',
  1106. })}
  1107. </span>
  1108. </div>
  1109. </div>
  1110. <div
  1111. ref={r =>
  1112. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  1113. }
  1114. className={
  1115. props.index % 2 === 1
  1116. ? RIGHT_COLUMN_ODD_CLASSNAME
  1117. : RIGHT_COLUMN_EVEN_CLASSNAME
  1118. }
  1119. />
  1120. </div>
  1121. );
  1122. }
  1123. return null;
  1124. }
  1125. function RenderPlaceholderRow(props: {
  1126. index: number;
  1127. manager: VirtualizedViewManager;
  1128. node: TraceTreeNode<TraceTree.NodeValue>;
  1129. style: React.CSSProperties;
  1130. theme: Theme;
  1131. }) {
  1132. return (
  1133. <div
  1134. key={props.index}
  1135. className="TraceRow"
  1136. style={{
  1137. top: props.style.top,
  1138. height: props.style.height,
  1139. pointerEvents: 'none',
  1140. color: props.theme.subText,
  1141. paddingLeft: 8,
  1142. }}
  1143. >
  1144. <div
  1145. className="TraceLeftColumn"
  1146. style={{width: props.manager.columns.list.width * 100 + '%'}}
  1147. >
  1148. <div
  1149. className="TraceLeftColumnInner"
  1150. style={{
  1151. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  1152. }}
  1153. >
  1154. <div
  1155. className={`TraceChildrenCountWrapper ${isTraceNode(props.node) ? 'Root' : ''}`}
  1156. >
  1157. <Connectors node={props.node} manager={props.manager} />
  1158. {props.node.children.length > 0 || props.node.canFetch ? (
  1159. <ChildrenButton
  1160. icon="+"
  1161. status={props.node.fetchStatus}
  1162. expanded={props.node.expanded || props.node.zoomedIn}
  1163. onClick={() => void 0}
  1164. >
  1165. {props.node.children.length > 0
  1166. ? COUNT_FORMATTER.format(props.node.children.length)
  1167. : null}
  1168. </ChildrenButton>
  1169. ) : null}
  1170. </div>
  1171. <Placeholder
  1172. className="Placeholder"
  1173. height="12px"
  1174. width={randomBetween(20, 80) + '%'}
  1175. style={{
  1176. transition: 'all 30s ease-out',
  1177. }}
  1178. />
  1179. </div>
  1180. </div>
  1181. <div
  1182. className={
  1183. props.index % 2 === 1 ? RIGHT_COLUMN_ODD_CLASSNAME : RIGHT_COLUMN_EVEN_CLASSNAME
  1184. }
  1185. style={{
  1186. width: props.manager.columns.span_list.width * 100 + '%',
  1187. }}
  1188. >
  1189. <Placeholder
  1190. className="Placeholder"
  1191. height="12px"
  1192. width={randomBetween(20, 80) + '%'}
  1193. style={{
  1194. transition: 'all 30s ease-out',
  1195. transform: `translate(${randomBetween(0, 200) + 'px'}, 0)`,
  1196. }}
  1197. />
  1198. </div>
  1199. </div>
  1200. );
  1201. }
  1202. function randomBetween(min: number, max: number) {
  1203. return Math.floor(Math.random() * (max - min + 1) + min);
  1204. }
  1205. function Connectors(props: {
  1206. manager: VirtualizedViewManager;
  1207. node: TraceTreeNode<TraceTree.NodeValue>;
  1208. }) {
  1209. const hasChildren =
  1210. (props.node.expanded || props.node.zoomedIn) && props.node.children.length > 0;
  1211. const showVerticalConnector =
  1212. hasChildren || (props.node.value && isParentAutogroupedNode(props.node));
  1213. // If the tail node of the collapsed node has no children,
  1214. // we don't want to render the vertical connector as no children
  1215. // are being rendered as the chain is entirely collapsed
  1216. const hideVerticalConnector =
  1217. showVerticalConnector &&
  1218. props.node.value &&
  1219. props.node instanceof ParentAutogroupNode &&
  1220. (!props.node.tail.children.length ||
  1221. (!props.node.tail.expanded && !props.node.expanded));
  1222. return (
  1223. <Fragment>
  1224. {props.node.connectors.map((c, i) => {
  1225. return (
  1226. <span
  1227. key={i}
  1228. style={{
  1229. left: -(
  1230. Math.abs(Math.abs(c) - props.node.depth) * props.manager.row_depth_padding
  1231. ),
  1232. }}
  1233. className={`TraceVerticalConnector ${c < 0 ? 'Orphaned' : ''}`}
  1234. />
  1235. );
  1236. })}
  1237. {showVerticalConnector && !hideVerticalConnector ? (
  1238. <span className="TraceExpandedVerticalConnector" />
  1239. ) : null}
  1240. {props.node.isLastChild ? (
  1241. <span className="TraceVerticalLastChildConnector" />
  1242. ) : (
  1243. <span className="TraceVerticalConnector" />
  1244. )}
  1245. </Fragment>
  1246. );
  1247. }
  1248. function ChildrenButton(props: {
  1249. children: React.ReactNode;
  1250. expanded: boolean;
  1251. icon: React.ReactNode;
  1252. onClick: (e: React.MouseEvent) => void;
  1253. status: TraceTreeNode<any>['fetchStatus'] | undefined;
  1254. }) {
  1255. return (
  1256. <button className={`TraceChildrenCount`} onClick={props.onClick}>
  1257. <div className="TraceChildrenCountContent">{props.children}</div>
  1258. <div className="TraceChildrenCountAction">
  1259. {props.icon}
  1260. {props.status === 'loading' ? (
  1261. <LoadingIndicator className="TraceActionsLoadingIndicator" size={8} />
  1262. ) : null}
  1263. </div>
  1264. </button>
  1265. );
  1266. }
  1267. interface TraceBarProps {
  1268. color: string;
  1269. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1270. manager: VirtualizedViewManager;
  1271. node_space: [number, number] | null;
  1272. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1273. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1274. virtualized_index: number;
  1275. }
  1276. function TraceBar(props: TraceBarProps) {
  1277. if (!props.node_space) {
  1278. return null;
  1279. }
  1280. const duration = formatTraceDuration(props.node_space[1]);
  1281. const spanTransform = props.manager.computeSpanCSSMatrixTransform(props.node_space);
  1282. return (
  1283. <Fragment>
  1284. <div
  1285. ref={r =>
  1286. props.manager.registerSpanBarRef(r, props.node_space!, props.virtualized_index)
  1287. }
  1288. className="TraceBar"
  1289. style={
  1290. {
  1291. transform: `matrix(${spanTransform.join(',')})`,
  1292. '--inverse-span-scale': 1 / spanTransform[0],
  1293. backgroundColor: props.color,
  1294. // unknown css variables cannot be part of the style object
  1295. } as React.CSSProperties
  1296. }
  1297. >
  1298. {props.profiles.length > 0 ? (
  1299. <Profiles
  1300. node_space={props.node_space}
  1301. profiles={props.profiles}
  1302. manager={props.manager}
  1303. />
  1304. ) : null}
  1305. {props.errors.size > 0 ? (
  1306. <Errors
  1307. node_space={props.node_space}
  1308. errors={props.errors}
  1309. manager={props.manager}
  1310. />
  1311. ) : null}
  1312. {props.performance_issues.size > 0 ? (
  1313. <PerformanceIssues
  1314. manager={props.manager}
  1315. node_space={props.node_space}
  1316. performance_issues={props.performance_issues}
  1317. />
  1318. ) : null}
  1319. </div>
  1320. <div
  1321. ref={r =>
  1322. props.manager.registerSpanBarTextRef(
  1323. r,
  1324. duration,
  1325. props.node_space!,
  1326. props.virtualized_index
  1327. )
  1328. }
  1329. className="TraceBarDuration"
  1330. >
  1331. {duration}
  1332. </div>
  1333. </Fragment>
  1334. );
  1335. }
  1336. interface InvisibleTraceBarProps {
  1337. children: React.ReactNode;
  1338. manager: VirtualizedViewManager;
  1339. node_space: [number, number] | null;
  1340. virtualizedIndex: number;
  1341. }
  1342. function InvisibleTraceBar(props: InvisibleTraceBarProps) {
  1343. if (!props.node_space || !props.children) {
  1344. return null;
  1345. }
  1346. const spanTransform = `translateX(${props.manager.computeTransformXFromTimestamp(props.node_space[0])}px)`;
  1347. return (
  1348. <div
  1349. ref={r =>
  1350. props.manager.registerInvisibleBarRef(
  1351. r,
  1352. props.node_space!,
  1353. props.virtualizedIndex
  1354. )
  1355. }
  1356. className="TraceBar Invisible"
  1357. style={
  1358. {
  1359. transform: spanTransform,
  1360. // undefined css variables break style rules
  1361. '--inverse-span-scale': 1,
  1362. // unknown css variables cannot be part of the style object
  1363. } as React.CSSProperties
  1364. }
  1365. onDoubleClick={e => {
  1366. e.stopPropagation();
  1367. props.manager.onZoomIntoSpace(props.node_space!);
  1368. }}
  1369. >
  1370. {props.children}
  1371. </div>
  1372. );
  1373. }
  1374. interface PerformanceIssuesProps {
  1375. manager: VirtualizedViewManager;
  1376. node_space: [number, number] | null;
  1377. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1378. }
  1379. function PerformanceIssues(props: PerformanceIssuesProps) {
  1380. const performance_issues = useMemo(() => {
  1381. return [...props.performance_issues];
  1382. }, [props.performance_issues]);
  1383. if (!props.performance_issues.size) {
  1384. return null;
  1385. }
  1386. return (
  1387. <Fragment>
  1388. {performance_issues.map((issue, _i) => {
  1389. const timestamp = issue.start * 1e3;
  1390. // Clamp the issue timestamp to the span's timestamp
  1391. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1392. clamp(
  1393. timestamp,
  1394. props.node_space![0],
  1395. props.node_space![0] + props.node_space![1]
  1396. ),
  1397. props.node_space!
  1398. );
  1399. const max_width = 100 - left;
  1400. const issue_duration = (issue.end - issue.start) * 1e3;
  1401. const width = clamp((issue_duration / props.node_space![1]) * 100, 0, max_width);
  1402. return (
  1403. <div
  1404. key={issue.event_id}
  1405. className="TracePerformanceIssue"
  1406. style={{left: left * 100 + '%', width: width + '%'}}
  1407. >
  1408. <div className={`TraceIcon performance_issue`} style={{left: 0}}>
  1409. <TraceIcons.Icon event={issue} />
  1410. </div>
  1411. </div>
  1412. );
  1413. })}
  1414. </Fragment>
  1415. );
  1416. }
  1417. interface ErrorsProps {
  1418. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1419. manager: VirtualizedViewManager;
  1420. node_space: [number, number] | null;
  1421. }
  1422. function Errors(props: ErrorsProps) {
  1423. const errors = useMemo(() => {
  1424. return [...props.errors];
  1425. }, [props.errors]);
  1426. if (!props.errors.size) {
  1427. return null;
  1428. }
  1429. return (
  1430. <Fragment>
  1431. {errors.map((error, _i) => {
  1432. const timestamp = error.timestamp ? error.timestamp * 1e3 : props.node_space![0];
  1433. // Clamp the error timestamp to the span's timestamp
  1434. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1435. clamp(
  1436. timestamp,
  1437. props.node_space![0],
  1438. props.node_space![0] + props.node_space![1]
  1439. ),
  1440. props.node_space!
  1441. );
  1442. return (
  1443. <div
  1444. key={error.event_id}
  1445. className={`TraceIcon ${error.level}`}
  1446. style={{left: left * 100 + '%'}}
  1447. >
  1448. <TraceIcons.Icon event={error} />
  1449. </div>
  1450. );
  1451. })}
  1452. </Fragment>
  1453. );
  1454. }
  1455. interface ProfilesProps {
  1456. manager: VirtualizedViewManager;
  1457. node_space: [number, number] | null;
  1458. profiles: TraceTree.Profile[];
  1459. }
  1460. function Profiles(props: ProfilesProps) {
  1461. if (!props.profiles.length) {
  1462. return null;
  1463. }
  1464. return (
  1465. <Fragment>
  1466. {props.profiles.map((profile, _i) => {
  1467. const timestamp = profile.space[0];
  1468. // Clamp the profile timestamp to the span's timestamp
  1469. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1470. clamp(
  1471. timestamp,
  1472. props.node_space![0],
  1473. props.node_space![0] + props.node_space![1]
  1474. ),
  1475. props.node_space!
  1476. );
  1477. return (
  1478. <div
  1479. key={profile.profile_id}
  1480. className="TraceIcon profile"
  1481. style={{left: left * 100 + '%'}}
  1482. >
  1483. <TraceIcons.Icon event={profile} />
  1484. </div>
  1485. );
  1486. })}
  1487. </Fragment>
  1488. );
  1489. }
  1490. interface AutogroupedTraceBarProps {
  1491. color: string;
  1492. entire_space: [number, number] | null;
  1493. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1494. manager: VirtualizedViewManager;
  1495. node_spaces: [number, number][];
  1496. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1497. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1498. virtualized_index: number;
  1499. }
  1500. function AutogroupedTraceBar(props: AutogroupedTraceBarProps) {
  1501. if (props.node_spaces && props.node_spaces.length <= 1) {
  1502. return (
  1503. <TraceBar
  1504. color={props.color}
  1505. node_space={props.entire_space}
  1506. manager={props.manager}
  1507. virtualized_index={props.virtualized_index}
  1508. errors={props.errors}
  1509. performance_issues={props.performance_issues}
  1510. profiles={props.profiles}
  1511. />
  1512. );
  1513. }
  1514. if (!props.node_spaces || !props.entire_space) {
  1515. return null;
  1516. }
  1517. const duration = formatTraceDuration(props.entire_space[1]);
  1518. const spanTransform = props.manager.computeSpanCSSMatrixTransform(props.entire_space);
  1519. return (
  1520. <Fragment>
  1521. <div
  1522. ref={r =>
  1523. props.manager.registerSpanBarRef(
  1524. r,
  1525. props.entire_space!,
  1526. props.virtualized_index
  1527. )
  1528. }
  1529. className="TraceBar Invisible"
  1530. style={{
  1531. transform: `matrix(${spanTransform.join(',')})`,
  1532. backgroundColor: props.color,
  1533. }}
  1534. >
  1535. {props.node_spaces.map((node_space, i) => {
  1536. const width = node_space[1] / props.entire_space![1];
  1537. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1538. node_space[0],
  1539. props.entire_space!
  1540. );
  1541. return (
  1542. <div
  1543. key={i}
  1544. className="TraceBar"
  1545. style={{
  1546. left: `${left * 100}%`,
  1547. width: `${width * 100}%`,
  1548. backgroundColor: props.color,
  1549. }}
  1550. />
  1551. );
  1552. })}
  1553. {props.profiles.length > 0 ? (
  1554. <Profiles
  1555. node_space={props.entire_space}
  1556. profiles={props.profiles}
  1557. manager={props.manager}
  1558. />
  1559. ) : null}
  1560. {props.errors.size > 0 ? (
  1561. <Errors
  1562. node_space={props.entire_space}
  1563. errors={props.errors}
  1564. manager={props.manager}
  1565. />
  1566. ) : null}
  1567. {props.performance_issues.size > 0 ? (
  1568. <PerformanceIssues
  1569. node_space={props.entire_space}
  1570. performance_issues={props.performance_issues}
  1571. manager={props.manager}
  1572. />
  1573. ) : null}
  1574. </div>
  1575. <div
  1576. ref={r =>
  1577. props.manager.registerSpanBarTextRef(
  1578. r,
  1579. duration,
  1580. props.entire_space!,
  1581. props.virtualized_index
  1582. )
  1583. }
  1584. className="TraceBarDuration"
  1585. >
  1586. {duration}
  1587. </div>
  1588. </Fragment>
  1589. );
  1590. }
  1591. /**
  1592. * This is a wrapper around the Trace component to apply styles
  1593. * to the trace tree. It exists because we _do not_ want to trigger
  1594. * emotion's css parsing logic as it is very slow and will cause
  1595. * the scrolling to flicker.
  1596. */
  1597. const TraceStylingWrapper = styled('div')`
  1598. margin: auto;
  1599. overscroll-behavior: none;
  1600. box-shadow: 0 0 0 1px ${p => p.theme.border};
  1601. position: absolute;
  1602. left: 0;
  1603. top: 0;
  1604. width: 100%;
  1605. height: 100%;
  1606. grid-area: trace;
  1607. padding-top: 26px;
  1608. &.WithIndicators {
  1609. padding-top: 44px;
  1610. &:before {
  1611. height: 44px;
  1612. .TraceScrollbarContainer {
  1613. height: 44px;
  1614. }
  1615. }
  1616. .TraceIndicator.Timeline {
  1617. .TraceIndicatorLabel {
  1618. top: 26px;
  1619. }
  1620. .TraceIndicatorLine {
  1621. top: 30px;
  1622. }
  1623. }
  1624. }
  1625. &:before {
  1626. content: '';
  1627. position: absolute;
  1628. left: 0;
  1629. top: 0;
  1630. width: 100%;
  1631. height: 26px;
  1632. background-color: ${p => p.theme.backgroundSecondary};
  1633. border-bottom: 1px solid ${p => p.theme.border};
  1634. }
  1635. &.Loading {
  1636. .TraceRow {
  1637. .TraceLeftColumnInner {
  1638. width: 100%;
  1639. }
  1640. }
  1641. .TraceRightColumn {
  1642. background-color: transparent !important;
  1643. }
  1644. .TraceDivider {
  1645. pointer-events: none;
  1646. }
  1647. }
  1648. .TraceScrollbarContainer {
  1649. left: 0;
  1650. top: 0;
  1651. height: 26px;
  1652. position: absolute;
  1653. overflow-x: auto;
  1654. overscroll-behavior: none;
  1655. will-change: transform;
  1656. .TraceScrollbarScroller {
  1657. height: 1px;
  1658. pointer-events: none;
  1659. visibility: hidden;
  1660. }
  1661. .TraceScrollbarHandle {
  1662. width: 24px;
  1663. height: 12px;
  1664. border-radius: 6px;
  1665. }
  1666. }
  1667. .TraceDivider {
  1668. position: absolute;
  1669. height: 100%;
  1670. background-color: transparent;
  1671. top: 0;
  1672. cursor: col-resize;
  1673. z-index: 10;
  1674. transform: translateX(calc(var(--translate-x) * 1px));
  1675. &:before {
  1676. content: '';
  1677. position: absolute;
  1678. width: 1px;
  1679. height: 100%;
  1680. background-color: ${p => p.theme.border};
  1681. left: 50%;
  1682. }
  1683. &:hover {
  1684. &:before {
  1685. background-color: ${p => p.theme.purple300};
  1686. }
  1687. }
  1688. }
  1689. .TraceIndicatorContainer {
  1690. overflow: hidden;
  1691. width: 100%;
  1692. height: 100%;
  1693. position: absolute;
  1694. right: 0;
  1695. top: 0;
  1696. transform: translateX(calc(var(--translate-x) * 1px));
  1697. z-index: 10;
  1698. pointer-events: none;
  1699. }
  1700. .TraceIndicator {
  1701. z-index: 1;
  1702. width: 3px;
  1703. height: 100%;
  1704. top: 0;
  1705. position: absolute;
  1706. &:hover {
  1707. z-index: 10;
  1708. }
  1709. .TraceIndicatorLabel {
  1710. min-width: 34px;
  1711. text-align: center;
  1712. position: absolute;
  1713. font-size: 10px;
  1714. font-weight: bold;
  1715. color: ${p => p.theme.textColor};
  1716. background-color: ${p => p.theme.background};
  1717. border-radius: ${p => p.theme.borderRadius};
  1718. border: 1px solid ${p => p.theme.border};
  1719. padding: 2px;
  1720. display: inline-block;
  1721. line-height: 1;
  1722. margin-top: 2px;
  1723. white-space: nowrap;
  1724. }
  1725. .TraceIndicatorLine {
  1726. width: 1px;
  1727. height: 100%;
  1728. top: 20px;
  1729. position: absolute;
  1730. left: 50%;
  1731. transform: translateX(-2px);
  1732. background: repeating-linear-gradient(
  1733. to bottom,
  1734. transparent 0 4px,
  1735. ${p => p.theme.textColor} 4px 8px
  1736. )
  1737. 80%/2px 100% no-repeat;
  1738. }
  1739. &.Errored {
  1740. .TraceIndicatorLabel {
  1741. border: 1px solid ${p => p.theme.error};
  1742. color: ${p => p.theme.error};
  1743. }
  1744. .TraceIndicatorLine {
  1745. background: repeating-linear-gradient(
  1746. to bottom,
  1747. transparent 0 4px,
  1748. ${p => p.theme.error} 4px 8px
  1749. )
  1750. 80%/2px 100% no-repeat;
  1751. }
  1752. }
  1753. &.Timeline {
  1754. opacity: 1;
  1755. z-index: 1;
  1756. pointer-events: none;
  1757. .TraceIndicatorLabel {
  1758. font-weight: normal;
  1759. min-width: 0;
  1760. top: 8px;
  1761. width: auto;
  1762. border: none;
  1763. background-color: transparent;
  1764. color: ${p => p.theme.subText};
  1765. }
  1766. .TraceIndicatorLine {
  1767. background: ${p => p.theme.translucentGray100};
  1768. top: 8px;
  1769. }
  1770. }
  1771. }
  1772. .TraceRow {
  1773. display: flex;
  1774. align-items: center;
  1775. position: absolute;
  1776. height: 24px;
  1777. width: 100%;
  1778. transition: none;
  1779. font-size: ${p => p.theme.fontSizeSmall};
  1780. --row-background-odd: ${p => p.theme.translucentSurface100};
  1781. --row-background-hover: ${p => p.theme.translucentSurface100};
  1782. --row-background-focused: ${p => p.theme.translucentSurface200};
  1783. --row-outline: ${p => p.theme.blue300};
  1784. --row-children-button-border-color: ${p => p.theme.border};
  1785. /* false positive for grid layout */
  1786. /* stylelint-disable */
  1787. &.info {
  1788. }
  1789. &.warning {
  1790. }
  1791. &.error,
  1792. &.fatal,
  1793. &.performance_issue {
  1794. --autogrouped: ${p => p.theme.error};
  1795. --row-children-button-border-color: ${p => p.theme.error};
  1796. --row-outline: ${p => p.theme.error};
  1797. }
  1798. &.default {
  1799. }
  1800. &.unknown {
  1801. }
  1802. &.Hidden {
  1803. position: absolute;
  1804. height: 100%;
  1805. width: 100%;
  1806. top: 0;
  1807. z-index: -1;
  1808. &:hover {
  1809. background-color: transparent;
  1810. }
  1811. * {
  1812. cursor: default !important;
  1813. }
  1814. }
  1815. .TraceIcon {
  1816. position: absolute;
  1817. top: 50%;
  1818. transform: translate(-50%, -50%) scaleX(var(--inverse-span-scale));
  1819. background-color: ${p => p.theme.background};
  1820. width: 18px !important;
  1821. height: 18px !important;
  1822. border-radius: 50%;
  1823. display: flex;
  1824. align-items: center;
  1825. justify-content: center;
  1826. &.info {
  1827. background-color: var(--info);
  1828. }
  1829. &.warning {
  1830. background-color: var(--warning);
  1831. }
  1832. &.error,
  1833. &.fatal {
  1834. background-color: var(--error);
  1835. }
  1836. &.performance_issue {
  1837. background-color: var(--performance-issue);
  1838. }
  1839. &.default {
  1840. background-color: var(--default);
  1841. }
  1842. &.unknown {
  1843. background-color: var(--unknown);
  1844. }
  1845. &.profile {
  1846. background-color: var(--profile);
  1847. }
  1848. svg {
  1849. width: 12px;
  1850. height: 12px;
  1851. fill: ${p => p.theme.white};
  1852. }
  1853. &.profile svg {
  1854. margin-left: 2px;
  1855. }
  1856. &.info,
  1857. &.warning,
  1858. &.performance_issue,
  1859. &.default,
  1860. &.unknown {
  1861. svg {
  1862. transform: translateY(-1px);
  1863. }
  1864. }
  1865. }
  1866. .TracePerformanceIssue {
  1867. position: absolute;
  1868. top: 0;
  1869. display: flex;
  1870. align-items: center;
  1871. justify-content: flex-start;
  1872. background-color: var(--performance-issue);
  1873. height: 16px;
  1874. }
  1875. .TraceRightColumn.Odd {
  1876. background-color: var(--row-background-odd);
  1877. }
  1878. &:hover {
  1879. background-color: var(--row-background-hovered);
  1880. }
  1881. &.Highlight {
  1882. box-shadow: inset 0 0 0 1px ${p => p.theme.blue200} !important;
  1883. .TraceLeftColumn {
  1884. box-shadow: inset 0px 0 0px 1px ${p => p.theme.blue200} !important;
  1885. }
  1886. }
  1887. &.Highlight,
  1888. &:focus,
  1889. &[tabindex='0'] {
  1890. outline: none;
  1891. background-color: var(--row-background-focused);
  1892. .TraceRightColumn.Odd {
  1893. background-color: transparent !important;
  1894. }
  1895. }
  1896. &:focus,
  1897. &[tabindex='0'] {
  1898. background-color: var(--row-background-focused);
  1899. box-shadow: inset 0 0 0 1px var(--row-outline) !important;
  1900. .TraceLeftColumn {
  1901. box-shadow: inset 0px 0 0px 1px var(--row-outline) !important;
  1902. }
  1903. .TraceRightColumn.Odd {
  1904. background-color: transparent !important;
  1905. }
  1906. }
  1907. &.SearchResult {
  1908. background-color: ${p => p.theme.yellow100};
  1909. .TraceRightColumn {
  1910. background-color: transparent;
  1911. }
  1912. }
  1913. &.Autogrouped {
  1914. color: ${p => p.theme.blue300};
  1915. .TraceDescription {
  1916. font-weight: bold;
  1917. }
  1918. .TraceChildrenCountWrapper {
  1919. button {
  1920. color: ${p => p.theme.white};
  1921. background-color: ${p => p.theme.blue300};
  1922. }
  1923. svg {
  1924. fill: ${p => p.theme.white};
  1925. }
  1926. }
  1927. }
  1928. }
  1929. .TraceLeftColumn {
  1930. height: 100%;
  1931. white-space: nowrap;
  1932. display: flex;
  1933. align-items: center;
  1934. overflow: hidden;
  1935. will-change: width;
  1936. box-shadow: inset 1px 0 0px 0px transparent;
  1937. cursor: pointer;
  1938. width: calc(var(--list-column-width) * 100%);
  1939. .TraceLeftColumnInner {
  1940. height: 100%;
  1941. white-space: nowrap;
  1942. display: flex;
  1943. align-items: center;
  1944. will-change: transform;
  1945. transform-origin: left center;
  1946. padding-right: ${space(2)};
  1947. img {
  1948. width: 16px;
  1949. height: 16px;
  1950. }
  1951. }
  1952. }
  1953. .TraceRightColumn {
  1954. height: 100%;
  1955. overflow: hidden;
  1956. position: relative;
  1957. display: flex;
  1958. align-items: center;
  1959. will-change: width;
  1960. z-index: 1;
  1961. cursor: pointer;
  1962. width: calc(var(--span-column-width) * 100%);
  1963. &:hover {
  1964. .TraceArrow.Visible {
  1965. opacity: 1;
  1966. transition: 300ms 300ms ease-out;
  1967. pointer-events: auto;
  1968. }
  1969. }
  1970. }
  1971. .TraceBar {
  1972. position: absolute;
  1973. height: 16px;
  1974. width: 100%;
  1975. background-color: black;
  1976. transform-origin: left center;
  1977. &.Invisible {
  1978. background-color: transparent !important;
  1979. > div {
  1980. height: 100%;
  1981. }
  1982. }
  1983. svg {
  1984. width: 14px;
  1985. height: 14px;
  1986. }
  1987. }
  1988. .TraceArrow {
  1989. position: absolute;
  1990. pointer-events: none;
  1991. top: 0;
  1992. width: 14px;
  1993. height: 24px;
  1994. opacity: 0;
  1995. background-color: transparent;
  1996. border: none;
  1997. transition: 60ms ease-out;
  1998. font-size: ${p => p.theme.fontSizeMedium};
  1999. color: ${p => p.theme.subText};
  2000. padding: 0 2px;
  2001. display: flex;
  2002. align-items: center;
  2003. svg {
  2004. fill: ${p => p.theme.subText};
  2005. }
  2006. &.Left {
  2007. left: 0;
  2008. }
  2009. &.Right {
  2010. right: 0;
  2011. transform: rotate(180deg);
  2012. }
  2013. }
  2014. .TraceBarDuration {
  2015. display: inline-block;
  2016. transform-origin: left center;
  2017. font-size: ${p => p.theme.fontSizeExtraSmall};
  2018. color: ${p => p.theme.gray300};
  2019. white-space: nowrap;
  2020. font-variant-numeric: tabular-nums;
  2021. position: absolute;
  2022. }
  2023. .TraceChildrenCount {
  2024. height: 16px;
  2025. white-space: nowrap;
  2026. min-width: 30px;
  2027. display: flex;
  2028. align-items: center;
  2029. justify-content: center;
  2030. border-radius: 99px;
  2031. padding: 0px 4px;
  2032. transition: all 0.15s ease-in-out;
  2033. background: ${p => p.theme.background};
  2034. border: 2px solid var(--row-children-button-border-color);
  2035. line-height: 0;
  2036. z-index: 1;
  2037. font-size: 10px;
  2038. box-shadow: ${p => p.theme.dropShadowLight};
  2039. margin-right: 8px;
  2040. .TraceChildrenCountContent {
  2041. + .TraceChildrenCountAction {
  2042. margin-left: 2px;
  2043. }
  2044. }
  2045. .TraceChildrenCountAction {
  2046. position: relative;
  2047. display: flex;
  2048. align-items: center;
  2049. justify-content: center;
  2050. }
  2051. .TraceActionsLoadingIndicator {
  2052. margin: 0;
  2053. position: absolute;
  2054. top: 50%;
  2055. left: 50%;
  2056. transform: translate(-50%, -50%);
  2057. background-color: ${p => p.theme.background};
  2058. animation: show 0.1s ease-in-out forwards;
  2059. @keyframes show {
  2060. from {
  2061. opacity: 0;
  2062. transform: translate(-50%, -50%) scale(0.86);
  2063. }
  2064. to {
  2065. opacity: 1;
  2066. transform: translate(-50%, -50%) scale(1);
  2067. }
  2068. }
  2069. .loading-indicator {
  2070. border-width: 2px;
  2071. }
  2072. .loading-message {
  2073. display: none;
  2074. }
  2075. }
  2076. svg {
  2077. width: 7px;
  2078. transition: none;
  2079. }
  2080. }
  2081. .TraceChildrenCountWrapper {
  2082. display: flex;
  2083. justify-content: flex-end;
  2084. align-items: center;
  2085. min-width: 44px;
  2086. height: 100%;
  2087. position: relative;
  2088. button {
  2089. transition: none;
  2090. }
  2091. svg {
  2092. fill: currentColor;
  2093. }
  2094. &.Orphaned {
  2095. .TraceVerticalConnector,
  2096. .TraceVerticalLastChildConnector,
  2097. .TraceExpandedVerticalConnector {
  2098. border-left: 2px dashed ${p => p.theme.border};
  2099. }
  2100. &::before {
  2101. border-bottom: 2px dashed ${p => p.theme.border};
  2102. }
  2103. }
  2104. &.Root {
  2105. &:before,
  2106. .TraceVerticalLastChildConnector {
  2107. visibility: hidden;
  2108. }
  2109. }
  2110. &::before {
  2111. content: '';
  2112. display: block;
  2113. width: 50%;
  2114. height: 2px;
  2115. border-bottom: 2px solid ${p => p.theme.border};
  2116. position: absolute;
  2117. left: 0;
  2118. top: 50%;
  2119. transform: translateY(-50%);
  2120. }
  2121. &::after {
  2122. content: '';
  2123. background-color: ${p => p.theme.border};
  2124. border-radius: 50%;
  2125. height: 6px;
  2126. width: 6px;
  2127. position: absolute;
  2128. left: 50%;
  2129. top: 50%;
  2130. transform: translateY(-50%);
  2131. }
  2132. }
  2133. .TraceVerticalConnector {
  2134. position: absolute;
  2135. left: 0;
  2136. top: 0;
  2137. bottom: 0;
  2138. height: 100%;
  2139. width: 2px;
  2140. border-left: 2px solid ${p => p.theme.border};
  2141. &.Orphaned {
  2142. border-left: 2px dashed ${p => p.theme.border};
  2143. }
  2144. }
  2145. .TraceVerticalLastChildConnector {
  2146. position: absolute;
  2147. left: 0;
  2148. top: 0;
  2149. bottom: 0;
  2150. height: 50%;
  2151. width: 2px;
  2152. border-left: 2px solid ${p => p.theme.border};
  2153. border-bottom-left-radius: 4px;
  2154. }
  2155. .TraceExpandedVerticalConnector {
  2156. position: absolute;
  2157. bottom: 0;
  2158. height: 50%;
  2159. left: 50%;
  2160. width: 2px;
  2161. border-left: 2px solid ${p => p.theme.border};
  2162. }
  2163. .TraceOperation {
  2164. margin-left: 4px;
  2165. text-overflow: ellipsis;
  2166. white-space: nowrap;
  2167. font-weight: bold;
  2168. }
  2169. .TraceEmDash {
  2170. margin-left: 4px;
  2171. margin-right: 4px;
  2172. }
  2173. .TraceDescription {
  2174. white-space: nowrap;
  2175. }
  2176. `;