trace.tsx 66 KB

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