trace.tsx 68 KB

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