trace.tsx 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349
  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 showVerticalConnector =
  1210. ((props.node.expanded || props.node.zoomedIn) && props.node.children.length > 0) ||
  1211. (props.node.value && isParentAutogroupedNode(props.node));
  1212. // If the tail node of the collapsed node has no children,
  1213. // we don't want to render the vertical connector as no children
  1214. // are being rendered as the chain is entirely collapsed
  1215. const hideVerticalConnector =
  1216. showVerticalConnector &&
  1217. props.node.value &&
  1218. props.node instanceof ParentAutogroupNode &&
  1219. !props.node.tail.children.length;
  1220. return (
  1221. <Fragment>
  1222. {props.node.connectors.map((c, i) => {
  1223. return (
  1224. <div
  1225. key={i}
  1226. style={{
  1227. left: -(
  1228. Math.abs(Math.abs(c) - props.node.depth) * props.manager.row_depth_padding
  1229. ),
  1230. }}
  1231. className={`TraceVerticalConnector ${c < 0 ? 'Orphaned' : ''}`}
  1232. />
  1233. );
  1234. })}
  1235. {showVerticalConnector && !hideVerticalConnector ? (
  1236. <div className="TraceExpandedVerticalConnector" />
  1237. ) : null}
  1238. {props.node.isLastChild ? (
  1239. <div className="TraceVerticalLastChildConnector" />
  1240. ) : (
  1241. <div className="TraceVerticalConnector" />
  1242. )}
  1243. </Fragment>
  1244. );
  1245. }
  1246. function ChildrenButton(props: {
  1247. children: React.ReactNode;
  1248. expanded: boolean;
  1249. icon: React.ReactNode;
  1250. onClick: (e: React.MouseEvent) => void;
  1251. status: TraceTreeNode<any>['fetchStatus'] | undefined;
  1252. }) {
  1253. return (
  1254. <button className={`TraceChildrenCount`} onClick={props.onClick}>
  1255. <div className="TraceChildrenCountContent">{props.children}</div>
  1256. <div className="TraceChildrenCountAction">
  1257. {props.icon}
  1258. {props.status === 'loading' ? (
  1259. <LoadingIndicator className="TraceActionsLoadingIndicator" size={8} />
  1260. ) : null}
  1261. </div>
  1262. </button>
  1263. );
  1264. }
  1265. interface TraceBarProps {
  1266. color: string;
  1267. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1268. manager: VirtualizedViewManager;
  1269. node_space: [number, number] | null;
  1270. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1271. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1272. virtualized_index: number;
  1273. }
  1274. function TraceBar(props: TraceBarProps) {
  1275. if (!props.node_space) {
  1276. return null;
  1277. }
  1278. const duration = formatTraceDuration(props.node_space[1]);
  1279. const spanTransform = props.manager.computeSpanCSSMatrixTransform(props.node_space);
  1280. return (
  1281. <Fragment>
  1282. <div
  1283. ref={r =>
  1284. props.manager.registerSpanBarRef(r, props.node_space!, props.virtualized_index)
  1285. }
  1286. className="TraceBar"
  1287. style={
  1288. {
  1289. transform: `matrix(${spanTransform.join(',')})`,
  1290. '--inverse-span-scale': 1 / spanTransform[0],
  1291. backgroundColor: props.color,
  1292. // unknown css variables cannot be part of the style object
  1293. } as React.CSSProperties
  1294. }
  1295. >
  1296. {props.profiles.length > 0 ? (
  1297. <Profiles
  1298. node_space={props.node_space}
  1299. profiles={props.profiles}
  1300. manager={props.manager}
  1301. />
  1302. ) : null}
  1303. {props.errors.size > 0 ? (
  1304. <Errors
  1305. node_space={props.node_space}
  1306. errors={props.errors}
  1307. manager={props.manager}
  1308. />
  1309. ) : null}
  1310. {props.performance_issues.size > 0 ? (
  1311. <PerformanceIssues
  1312. manager={props.manager}
  1313. node_space={props.node_space}
  1314. performance_issues={props.performance_issues}
  1315. />
  1316. ) : null}
  1317. </div>
  1318. <div
  1319. ref={r =>
  1320. props.manager.registerSpanBarTextRef(
  1321. r,
  1322. duration,
  1323. props.node_space!,
  1324. props.virtualized_index
  1325. )
  1326. }
  1327. className="TraceBarDuration"
  1328. >
  1329. {duration}
  1330. </div>
  1331. </Fragment>
  1332. );
  1333. }
  1334. interface InvisibleTraceBarProps {
  1335. children: React.ReactNode;
  1336. manager: VirtualizedViewManager;
  1337. node_space: [number, number] | null;
  1338. virtualizedIndex: number;
  1339. }
  1340. function InvisibleTraceBar(props: InvisibleTraceBarProps) {
  1341. if (!props.node_space || !props.children) {
  1342. return null;
  1343. }
  1344. const spanTransform = `translateX(${props.manager.computeTransformXFromTimestamp(props.node_space[0])}px)`;
  1345. return (
  1346. <div
  1347. ref={r =>
  1348. props.manager.registerInvisibleBarRef(
  1349. r,
  1350. props.node_space!,
  1351. props.virtualizedIndex
  1352. )
  1353. }
  1354. className="TraceBar Invisible"
  1355. style={
  1356. {
  1357. transform: spanTransform,
  1358. // undefined css variables break style rules
  1359. '--inverse-span-scale': 1,
  1360. // unknown css variables cannot be part of the style object
  1361. } as React.CSSProperties
  1362. }
  1363. onDoubleClick={e => {
  1364. e.stopPropagation();
  1365. props.manager.onZoomIntoSpace(props.node_space!);
  1366. }}
  1367. >
  1368. {props.children}
  1369. </div>
  1370. );
  1371. }
  1372. interface PerformanceIssuesProps {
  1373. manager: VirtualizedViewManager;
  1374. node_space: [number, number] | null;
  1375. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1376. }
  1377. function PerformanceIssues(props: PerformanceIssuesProps) {
  1378. const performance_issues = useMemo(() => {
  1379. return [...props.performance_issues];
  1380. }, [props.performance_issues]);
  1381. if (!props.performance_issues.size) {
  1382. return null;
  1383. }
  1384. return (
  1385. <Fragment>
  1386. {performance_issues.map((issue, _i) => {
  1387. const timestamp = issue.start * 1e3;
  1388. // Clamp the issue timestamp to the span's timestamp
  1389. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1390. clamp(
  1391. timestamp,
  1392. props.node_space![0],
  1393. props.node_space![0] + props.node_space![1]
  1394. ),
  1395. props.node_space!
  1396. );
  1397. const max_width = 100 - left;
  1398. const issue_duration = (issue.end - issue.start) * 1e3;
  1399. const width = clamp((issue_duration / props.node_space![1]) * 100, 0, max_width);
  1400. return (
  1401. <div
  1402. key={issue.event_id}
  1403. className="TracePerformanceIssue"
  1404. style={{left: left * 100 + '%', width: width + '%'}}
  1405. >
  1406. <div className={`TraceIcon performance_issue`} style={{left: 0}}>
  1407. <TraceIcons.Icon event={issue} />
  1408. </div>
  1409. </div>
  1410. );
  1411. })}
  1412. </Fragment>
  1413. );
  1414. }
  1415. interface ErrorsProps {
  1416. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1417. manager: VirtualizedViewManager;
  1418. node_space: [number, number] | null;
  1419. }
  1420. function Errors(props: ErrorsProps) {
  1421. const errors = useMemo(() => {
  1422. return [...props.errors];
  1423. }, [props.errors]);
  1424. if (!props.errors.size) {
  1425. return null;
  1426. }
  1427. return (
  1428. <Fragment>
  1429. {errors.map((error, _i) => {
  1430. const timestamp = error.timestamp ? error.timestamp * 1e3 : props.node_space![0];
  1431. // Clamp the error timestamp to the span's timestamp
  1432. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1433. clamp(
  1434. timestamp,
  1435. props.node_space![0],
  1436. props.node_space![0] + props.node_space![1]
  1437. ),
  1438. props.node_space!
  1439. );
  1440. return (
  1441. <div
  1442. key={error.event_id}
  1443. className={`TraceIcon ${error.level}`}
  1444. style={{left: left * 100 + '%'}}
  1445. >
  1446. <TraceIcons.Icon event={error} />
  1447. </div>
  1448. );
  1449. })}
  1450. </Fragment>
  1451. );
  1452. }
  1453. interface ProfilesProps {
  1454. manager: VirtualizedViewManager;
  1455. node_space: [number, number] | null;
  1456. profiles: TraceTree.Profile[];
  1457. }
  1458. function Profiles(props: ProfilesProps) {
  1459. if (!props.profiles.length) {
  1460. return null;
  1461. }
  1462. return (
  1463. <Fragment>
  1464. {props.profiles.map((profile, _i) => {
  1465. const timestamp = profile.space[0];
  1466. // Clamp the profile timestamp to the span's timestamp
  1467. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1468. clamp(
  1469. timestamp,
  1470. props.node_space![0],
  1471. props.node_space![0] + props.node_space![1]
  1472. ),
  1473. props.node_space!
  1474. );
  1475. return (
  1476. <div
  1477. key={profile.profile_id}
  1478. className="TraceIcon profile"
  1479. style={{left: left * 100 + '%'}}
  1480. >
  1481. <TraceIcons.Icon event={profile} />
  1482. </div>
  1483. );
  1484. })}
  1485. </Fragment>
  1486. );
  1487. }
  1488. interface AutogroupedTraceBarProps {
  1489. color: string;
  1490. entire_space: [number, number] | null;
  1491. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1492. manager: VirtualizedViewManager;
  1493. node_spaces: [number, number][];
  1494. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1495. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1496. virtualized_index: number;
  1497. }
  1498. function AutogroupedTraceBar(props: AutogroupedTraceBarProps) {
  1499. if (props.node_spaces && props.node_spaces.length <= 1) {
  1500. return (
  1501. <TraceBar
  1502. color={props.color}
  1503. node_space={props.entire_space}
  1504. manager={props.manager}
  1505. virtualized_index={props.virtualized_index}
  1506. errors={props.errors}
  1507. performance_issues={props.performance_issues}
  1508. profiles={props.profiles}
  1509. />
  1510. );
  1511. }
  1512. if (!props.node_spaces || !props.entire_space) {
  1513. return null;
  1514. }
  1515. const duration = formatTraceDuration(props.entire_space[1]);
  1516. const spanTransform = props.manager.computeSpanCSSMatrixTransform(props.entire_space);
  1517. return (
  1518. <Fragment>
  1519. <div
  1520. ref={r =>
  1521. props.manager.registerSpanBarRef(
  1522. r,
  1523. props.entire_space!,
  1524. props.virtualized_index
  1525. )
  1526. }
  1527. className="TraceBar Invisible"
  1528. style={{
  1529. transform: `matrix(${spanTransform.join(',')})`,
  1530. backgroundColor: props.color,
  1531. }}
  1532. >
  1533. {props.node_spaces.map((node_space, i) => {
  1534. const width = node_space[1] / props.entire_space![1];
  1535. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1536. node_space[0],
  1537. props.entire_space!
  1538. );
  1539. return (
  1540. <div
  1541. key={i}
  1542. className="TraceBar"
  1543. style={{
  1544. left: `${left * 100}%`,
  1545. width: `${width * 100}%`,
  1546. backgroundColor: props.color,
  1547. }}
  1548. />
  1549. );
  1550. })}
  1551. {props.profiles.length > 0 ? (
  1552. <Profiles
  1553. node_space={props.entire_space}
  1554. profiles={props.profiles}
  1555. manager={props.manager}
  1556. />
  1557. ) : null}
  1558. {props.errors.size > 0 ? (
  1559. <Errors
  1560. node_space={props.entire_space}
  1561. errors={props.errors}
  1562. manager={props.manager}
  1563. />
  1564. ) : null}
  1565. {props.performance_issues.size > 0 ? (
  1566. <PerformanceIssues
  1567. node_space={props.entire_space}
  1568. performance_issues={props.performance_issues}
  1569. manager={props.manager}
  1570. />
  1571. ) : null}
  1572. </div>
  1573. <div
  1574. ref={r =>
  1575. props.manager.registerSpanBarTextRef(
  1576. r,
  1577. duration,
  1578. props.entire_space!,
  1579. props.virtualized_index
  1580. )
  1581. }
  1582. className="TraceBarDuration"
  1583. >
  1584. {duration}
  1585. </div>
  1586. </Fragment>
  1587. );
  1588. }
  1589. /**
  1590. * This is a wrapper around the Trace component to apply styles
  1591. * to the trace tree. It exists because we _do not_ want to trigger
  1592. * emotion's css parsing logic as it is very slow and will cause
  1593. * the scrolling to flicker.
  1594. */
  1595. const TraceStylingWrapper = styled('div')`
  1596. margin: auto;
  1597. overscroll-behavior: none;
  1598. box-shadow: 0 0 0 1px ${p => p.theme.border};
  1599. position: absolute;
  1600. left: 0;
  1601. top: 0;
  1602. width: 100%;
  1603. height: 100%;
  1604. grid-area: trace;
  1605. padding-top: 26px;
  1606. &.WithIndicators {
  1607. padding-top: 44px;
  1608. &:before {
  1609. height: 44px;
  1610. .TraceScrollbarContainer {
  1611. height: 44px;
  1612. }
  1613. }
  1614. .TraceIndicator.Timeline {
  1615. .TraceIndicatorLabel {
  1616. top: 26px;
  1617. }
  1618. .TraceIndicatorLine {
  1619. top: 30px;
  1620. }
  1621. }
  1622. }
  1623. &:before {
  1624. content: '';
  1625. position: absolute;
  1626. left: 0;
  1627. top: 0;
  1628. width: 100%;
  1629. height: 26px;
  1630. background-color: ${p => p.theme.backgroundSecondary};
  1631. border-bottom: 1px solid ${p => p.theme.border};
  1632. }
  1633. &.Loading {
  1634. .TraceRow {
  1635. .TraceLeftColumnInner {
  1636. width: 100%;
  1637. }
  1638. }
  1639. .TraceRightColumn {
  1640. background-color: transparent !important;
  1641. }
  1642. .TraceDivider {
  1643. pointer-events: none;
  1644. }
  1645. }
  1646. .TraceScrollbarContainer {
  1647. left: 0;
  1648. top: 0;
  1649. height: 26px;
  1650. position: absolute;
  1651. overflow-x: auto;
  1652. overscroll-behavior: none;
  1653. will-change: transform;
  1654. .TraceScrollbarScroller {
  1655. height: 1px;
  1656. pointer-events: none;
  1657. visibility: hidden;
  1658. }
  1659. .TraceScrollbarHandle {
  1660. width: 24px;
  1661. height: 12px;
  1662. border-radius: 6px;
  1663. }
  1664. }
  1665. .TraceDivider {
  1666. position: absolute;
  1667. height: 100%;
  1668. background-color: transparent;
  1669. top: 0;
  1670. cursor: col-resize;
  1671. z-index: 10;
  1672. transform: translateX(calc(var(--translate-x) * 1px));
  1673. &:before {
  1674. content: '';
  1675. position: absolute;
  1676. width: 1px;
  1677. height: 100%;
  1678. background-color: ${p => p.theme.border};
  1679. left: 50%;
  1680. }
  1681. &:hover {
  1682. &:before {
  1683. background-color: ${p => p.theme.purple300};
  1684. }
  1685. }
  1686. }
  1687. .TraceIndicatorContainer {
  1688. overflow: hidden;
  1689. width: 100%;
  1690. height: 100%;
  1691. position: absolute;
  1692. right: 0;
  1693. top: 0;
  1694. transform: translateX(calc(var(--translate-x) * 1px));
  1695. z-index: 10;
  1696. pointer-events: none;
  1697. }
  1698. .TraceIndicator {
  1699. z-index: 1;
  1700. width: 3px;
  1701. height: 100%;
  1702. top: 0;
  1703. position: absolute;
  1704. &:hover {
  1705. z-index: 10;
  1706. }
  1707. .TraceIndicatorLabel {
  1708. min-width: 34px;
  1709. text-align: center;
  1710. position: absolute;
  1711. font-size: 10px;
  1712. font-weight: bold;
  1713. color: ${p => p.theme.textColor};
  1714. background-color: ${p => p.theme.background};
  1715. border-radius: ${p => p.theme.borderRadius};
  1716. border: 1px solid ${p => p.theme.border};
  1717. padding: 2px;
  1718. display: inline-block;
  1719. line-height: 1;
  1720. margin-top: 2px;
  1721. white-space: nowrap;
  1722. }
  1723. .TraceIndicatorLine {
  1724. width: 1px;
  1725. height: 100%;
  1726. top: 20px;
  1727. position: absolute;
  1728. left: 50%;
  1729. transform: translateX(-2px);
  1730. background: repeating-linear-gradient(
  1731. to bottom,
  1732. transparent 0 4px,
  1733. ${p => p.theme.textColor} 4px 8px
  1734. )
  1735. 80%/2px 100% no-repeat;
  1736. }
  1737. &.Errored {
  1738. .TraceIndicatorLabel {
  1739. border: 1px solid ${p => p.theme.error};
  1740. color: ${p => p.theme.error};
  1741. }
  1742. .TraceIndicatorLine {
  1743. background: repeating-linear-gradient(
  1744. to bottom,
  1745. transparent 0 4px,
  1746. ${p => p.theme.error} 4px 8px
  1747. )
  1748. 80%/2px 100% no-repeat;
  1749. }
  1750. }
  1751. &.Timeline {
  1752. opacity: 1;
  1753. z-index: 1;
  1754. pointer-events: none;
  1755. .TraceIndicatorLabel {
  1756. font-weight: normal;
  1757. min-width: 0;
  1758. top: 8px;
  1759. width: auto;
  1760. border: none;
  1761. background-color: transparent;
  1762. color: ${p => p.theme.subText};
  1763. }
  1764. .TraceIndicatorLine {
  1765. background: ${p => p.theme.translucentGray100};
  1766. top: 8px;
  1767. }
  1768. }
  1769. }
  1770. .TraceRow {
  1771. display: flex;
  1772. align-items: center;
  1773. position: absolute;
  1774. height: 24px;
  1775. width: 100%;
  1776. transition: none;
  1777. font-size: ${p => p.theme.fontSizeSmall};
  1778. --row-background-odd: ${p => p.theme.translucentSurface100};
  1779. --row-background-hover: ${p => p.theme.translucentSurface100};
  1780. --row-background-focused: ${p => p.theme.translucentSurface200};
  1781. --row-outline: ${p => p.theme.blue300};
  1782. --row-children-button-border-color: ${p => p.theme.border};
  1783. /* false positive for grid layout */
  1784. /* stylelint-disable */
  1785. &.info {
  1786. }
  1787. &.warning {
  1788. }
  1789. &.error,
  1790. &.fatal,
  1791. &.performance_issue {
  1792. --autogrouped: ${p => p.theme.error};
  1793. --row-children-button-border-color: ${p => p.theme.error};
  1794. --row-outline: ${p => p.theme.error};
  1795. }
  1796. &.default {
  1797. }
  1798. &.unknown {
  1799. }
  1800. &.Hidden {
  1801. position: absolute;
  1802. height: 100%;
  1803. width: 100%;
  1804. top: 0;
  1805. z-index: -1;
  1806. &:hover {
  1807. background-color: transparent;
  1808. }
  1809. * {
  1810. cursor: default !important;
  1811. }
  1812. }
  1813. .TraceIcon {
  1814. position: absolute;
  1815. top: 50%;
  1816. transform: translate(-50%, -50%) scaleX(var(--inverse-span-scale));
  1817. background-color: ${p => p.theme.background};
  1818. width: 18px !important;
  1819. height: 18px !important;
  1820. border-radius: 50%;
  1821. display: flex;
  1822. align-items: center;
  1823. justify-content: center;
  1824. &.info {
  1825. background-color: var(--info);
  1826. }
  1827. &.warning {
  1828. background-color: var(--warning);
  1829. }
  1830. &.error,
  1831. &.fatal {
  1832. background-color: var(--error);
  1833. }
  1834. &.performance_issue {
  1835. background-color: var(--performance-issue);
  1836. }
  1837. &.default {
  1838. background-color: var(--default);
  1839. }
  1840. &.unknown {
  1841. background-color: var(--unknown);
  1842. }
  1843. &.profile {
  1844. background-color: var(--profile);
  1845. }
  1846. svg {
  1847. width: 12px;
  1848. height: 12px;
  1849. fill: ${p => p.theme.white};
  1850. }
  1851. &.profile svg {
  1852. margin-left: 2px;
  1853. }
  1854. &.info,
  1855. &.warning,
  1856. &.performance_issue,
  1857. &.default,
  1858. &.unknown {
  1859. svg {
  1860. transform: translateY(-1px);
  1861. }
  1862. }
  1863. }
  1864. .TracePerformanceIssue {
  1865. position: absolute;
  1866. top: 0;
  1867. display: flex;
  1868. align-items: center;
  1869. justify-content: flex-start;
  1870. background-color: var(--performance-issue);
  1871. height: 16px;
  1872. }
  1873. .TraceRightColumn.Odd {
  1874. background-color: var(--row-background-odd);
  1875. }
  1876. &:hover {
  1877. background-color: var(--row-background-hovered);
  1878. }
  1879. &.Highlight {
  1880. box-shadow: inset 0 0 0 1px ${p => p.theme.blue200} !important;
  1881. .TraceLeftColumn {
  1882. box-shadow: inset 0px 0 0px 1px ${p => p.theme.blue200} !important;
  1883. }
  1884. }
  1885. &.Highlight,
  1886. &:focus,
  1887. &[tabindex='0'] {
  1888. outline: none;
  1889. background-color: var(--row-background-focused);
  1890. .TraceRightColumn.Odd {
  1891. background-color: transparent !important;
  1892. }
  1893. }
  1894. &:focus,
  1895. &[tabindex='0'] {
  1896. background-color: var(--row-background-focused);
  1897. box-shadow: inset 0 0 0 1px var(--row-outline) !important;
  1898. .TraceLeftColumn {
  1899. box-shadow: inset 0px 0 0px 1px var(--row-outline) !important;
  1900. }
  1901. .TraceRightColumn.Odd {
  1902. background-color: transparent !important;
  1903. }
  1904. }
  1905. &.SearchResult {
  1906. background-color: ${p => p.theme.yellow100};
  1907. .TraceRightColumn {
  1908. background-color: transparent;
  1909. }
  1910. }
  1911. &.Autogrouped {
  1912. color: ${p => p.theme.blue300};
  1913. .TraceDescription {
  1914. font-weight: bold;
  1915. }
  1916. .TraceChildrenCountWrapper {
  1917. button {
  1918. color: ${p => p.theme.white};
  1919. background-color: ${p => p.theme.blue300};
  1920. }
  1921. svg {
  1922. fill: ${p => p.theme.white};
  1923. }
  1924. }
  1925. }
  1926. }
  1927. .TraceLeftColumn {
  1928. height: 100%;
  1929. white-space: nowrap;
  1930. display: flex;
  1931. align-items: center;
  1932. overflow: hidden;
  1933. will-change: width;
  1934. box-shadow: inset 1px 0 0px 0px transparent;
  1935. cursor: pointer;
  1936. width: calc(var(--list-column-width) * 100%);
  1937. .TraceLeftColumnInner {
  1938. height: 100%;
  1939. white-space: nowrap;
  1940. display: flex;
  1941. align-items: center;
  1942. will-change: transform;
  1943. transform-origin: left center;
  1944. padding-right: ${space(2)};
  1945. img {
  1946. width: 16px;
  1947. height: 16px;
  1948. }
  1949. }
  1950. }
  1951. .TraceRightColumn {
  1952. height: 100%;
  1953. overflow: hidden;
  1954. position: relative;
  1955. display: flex;
  1956. align-items: center;
  1957. will-change: width;
  1958. z-index: 1;
  1959. cursor: pointer;
  1960. width: calc(var(--span-column-width) * 100%);
  1961. &:hover {
  1962. .TraceArrow.Visible {
  1963. opacity: 1;
  1964. transition: 300ms 300ms ease-out;
  1965. pointer-events: auto;
  1966. }
  1967. }
  1968. }
  1969. .TraceBar {
  1970. position: absolute;
  1971. height: 16px;
  1972. width: 100%;
  1973. background-color: black;
  1974. transform-origin: left center;
  1975. &.Invisible {
  1976. background-color: transparent !important;
  1977. > div {
  1978. height: 100%;
  1979. }
  1980. }
  1981. svg {
  1982. width: 14px;
  1983. height: 14px;
  1984. }
  1985. }
  1986. .TraceArrow {
  1987. position: absolute;
  1988. pointer-events: none;
  1989. top: 0;
  1990. width: 14px;
  1991. height: 24px;
  1992. opacity: 0;
  1993. background-color: transparent;
  1994. border: none;
  1995. transition: 60ms ease-out;
  1996. font-size: ${p => p.theme.fontSizeMedium};
  1997. color: ${p => p.theme.subText};
  1998. padding: 0 2px;
  1999. display: flex;
  2000. align-items: center;
  2001. svg {
  2002. fill: ${p => p.theme.subText};
  2003. }
  2004. &.Left {
  2005. left: 0;
  2006. }
  2007. &.Right {
  2008. right: 0;
  2009. transform: rotate(180deg);
  2010. }
  2011. }
  2012. .TraceBarDuration {
  2013. display: inline-block;
  2014. transform-origin: left center;
  2015. font-size: ${p => p.theme.fontSizeExtraSmall};
  2016. color: ${p => p.theme.gray300};
  2017. white-space: nowrap;
  2018. font-variant-numeric: tabular-nums;
  2019. position: absolute;
  2020. }
  2021. .TraceChildrenCount {
  2022. height: 16px;
  2023. white-space: nowrap;
  2024. min-width: 30px;
  2025. display: flex;
  2026. align-items: center;
  2027. justify-content: center;
  2028. border-radius: 99px;
  2029. padding: 0px 4px;
  2030. transition: all 0.15s ease-in-out;
  2031. background: ${p => p.theme.background};
  2032. border: 2px solid var(--row-children-button-border-color);
  2033. line-height: 0;
  2034. z-index: 1;
  2035. font-size: 10px;
  2036. box-shadow: ${p => p.theme.dropShadowLight};
  2037. margin-right: 8px;
  2038. .TraceChildrenCountContent {
  2039. + .TraceChildrenCountAction {
  2040. margin-left: 2px;
  2041. }
  2042. }
  2043. .TraceChildrenCountAction {
  2044. position: relative;
  2045. display: flex;
  2046. align-items: center;
  2047. justify-content: center;
  2048. }
  2049. .TraceActionsLoadingIndicator {
  2050. margin: 0;
  2051. position: absolute;
  2052. top: 50%;
  2053. left: 50%;
  2054. transform: translate(-50%, -50%);
  2055. background-color: ${p => p.theme.background};
  2056. animation: show 0.1s ease-in-out forwards;
  2057. @keyframes show {
  2058. from {
  2059. opacity: 0;
  2060. transform: translate(-50%, -50%) scale(0.86);
  2061. }
  2062. to {
  2063. opacity: 1;
  2064. transform: translate(-50%, -50%) scale(1);
  2065. }
  2066. }
  2067. .loading-indicator {
  2068. border-width: 2px;
  2069. }
  2070. .loading-message {
  2071. display: none;
  2072. }
  2073. }
  2074. svg {
  2075. width: 7px;
  2076. transition: none;
  2077. }
  2078. }
  2079. .TraceChildrenCountWrapper {
  2080. display: flex;
  2081. justify-content: flex-end;
  2082. align-items: center;
  2083. min-width: 44px;
  2084. height: 100%;
  2085. position: relative;
  2086. button {
  2087. transition: none;
  2088. }
  2089. svg {
  2090. fill: currentColor;
  2091. }
  2092. &.Orphaned {
  2093. .TraceVerticalConnector,
  2094. .TraceVerticalLastChildConnector,
  2095. .TraceExpandedVerticalConnector {
  2096. border-left: 2px dashed ${p => p.theme.border};
  2097. }
  2098. &::before {
  2099. border-bottom: 2px dashed ${p => p.theme.border};
  2100. }
  2101. }
  2102. &.Root {
  2103. &:before,
  2104. .TraceVerticalLastChildConnector {
  2105. visibility: hidden;
  2106. }
  2107. }
  2108. &::before {
  2109. content: '';
  2110. display: block;
  2111. width: 50%;
  2112. height: 2px;
  2113. border-bottom: 2px solid ${p => p.theme.border};
  2114. position: absolute;
  2115. left: 0;
  2116. top: 50%;
  2117. transform: translateY(-50%);
  2118. }
  2119. &::after {
  2120. content: '';
  2121. background-color: ${p => p.theme.border};
  2122. border-radius: 50%;
  2123. height: 6px;
  2124. width: 6px;
  2125. position: absolute;
  2126. left: 50%;
  2127. top: 50%;
  2128. transform: translateY(-50%);
  2129. }
  2130. }
  2131. .TraceVerticalConnector {
  2132. position: absolute;
  2133. left: 0;
  2134. top: 0;
  2135. bottom: 0;
  2136. height: 100%;
  2137. width: 2px;
  2138. border-left: 2px solid ${p => p.theme.border};
  2139. &.Orphaned {
  2140. border-left: 2px dashed ${p => p.theme.border};
  2141. }
  2142. }
  2143. .TraceVerticalLastChildConnector {
  2144. position: absolute;
  2145. left: 0;
  2146. top: 0;
  2147. bottom: 0;
  2148. height: 50%;
  2149. width: 2px;
  2150. border-left: 2px solid ${p => p.theme.border};
  2151. border-bottom-left-radius: 4px;
  2152. }
  2153. .TraceExpandedVerticalConnector {
  2154. position: absolute;
  2155. bottom: 0;
  2156. height: 50%;
  2157. left: 50%;
  2158. width: 2px;
  2159. border-left: 2px solid ${p => p.theme.border};
  2160. }
  2161. .TraceOperation {
  2162. margin-left: 4px;
  2163. text-overflow: ellipsis;
  2164. white-space: nowrap;
  2165. font-weight: bold;
  2166. }
  2167. .TraceEmDash {
  2168. margin-left: 4px;
  2169. margin-right: 4px;
  2170. }
  2171. .TraceDescription {
  2172. white-space: nowrap;
  2173. }
  2174. `;