trace.tsx 69 KB

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