trace.tsx 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448
  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 queryParams = qs.parse(location.search);
  198. const maybeQueue = decodeScrollQueue(queryParams.node);
  199. if (maybeQueue || queryParams.eventId) {
  200. scrollQueueRef.current = {
  201. eventId: queryParams.eventId 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">
  940. {props.node.value.message ?? props.node.value.title}
  941. </span>
  942. </div>
  943. </div>
  944. <div
  945. ref={registerSpanColumnRef}
  946. className={spanColumnClassName}
  947. onDoubleClick={onSpanRowDoubleClick}
  948. >
  949. <InvisibleTraceBar
  950. node_space={props.node.space}
  951. manager={props.manager}
  952. virtualizedIndex={virtualized_index}
  953. >
  954. {typeof props.node.value.timestamp === 'number' ? (
  955. <div className={`TraceIcon ${props.node.value.level}`}>
  956. <TraceIcons.Icon event={props.node.value} />
  957. </div>
  958. ) : null}
  959. </InvisibleTraceBar>
  960. </div>
  961. </div>
  962. );
  963. }
  964. if (isNoDataNode(props.node)) {
  965. return (
  966. <div
  967. key={props.index}
  968. ref={r =>
  969. props.tabIndex === 0
  970. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  971. : null
  972. }
  973. tabIndex={props.tabIndex}
  974. className={`TraceRow ${rowSearchClassName}`}
  975. onClick={onRowClick}
  976. onKeyDown={onRowKeyDown}
  977. style={props.style}
  978. >
  979. <div className="TraceLeftColumn" ref={registerListColumnRef}>
  980. <div className="TraceLeftColumnInner" style={listColumnStyle}>
  981. <div className="TraceChildrenCountWrapper">
  982. <Connectors node={props.node} manager={props.manager} />
  983. </div>
  984. <span className="TraceOperation">{t('Empty')}</span>{' '}
  985. <strong className="TraceEmDash"> — </strong>
  986. <span className="TraceDescription">
  987. {tct('[type] did not report any span data', {
  988. type: props.node.parent
  989. ? isTransactionNode(props.node.parent)
  990. ? 'Transaction'
  991. : isSpanNode(props.node.parent)
  992. ? 'Span'
  993. : ''
  994. : '',
  995. })}
  996. </span>
  997. </div>
  998. </div>
  999. <div ref={registerSpanColumnRef} className={spanColumnClassName} />
  1000. </div>
  1001. );
  1002. }
  1003. return null;
  1004. }
  1005. function RenderPlaceholderRow(props: {
  1006. index: number;
  1007. manager: VirtualizedViewManager;
  1008. node: TraceTreeNode<TraceTree.NodeValue>;
  1009. style: React.CSSProperties;
  1010. theme: Theme;
  1011. }) {
  1012. return (
  1013. <div
  1014. key={props.index}
  1015. className="TraceRow"
  1016. style={{
  1017. transform: props.style.transform,
  1018. height: props.style.height,
  1019. pointerEvents: 'none',
  1020. color: props.theme.subText,
  1021. paddingLeft: 8,
  1022. }}
  1023. >
  1024. <div
  1025. className="TraceLeftColumn"
  1026. style={{width: props.manager.columns.list.width * 100 + '%'}}
  1027. >
  1028. <div
  1029. className="TraceLeftColumnInner"
  1030. style={{
  1031. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  1032. }}
  1033. >
  1034. <div
  1035. className={`TraceChildrenCountWrapper ${isTraceNode(props.node) ? 'Root' : ''}`}
  1036. >
  1037. <Connectors node={props.node} manager={props.manager} />
  1038. {props.node.children.length > 0 || props.node.canFetch ? (
  1039. <ChildrenButton
  1040. icon="+"
  1041. status={props.node.fetchStatus}
  1042. expanded={props.node.expanded || props.node.zoomedIn}
  1043. onClick={() => void 0}
  1044. >
  1045. {props.node.children.length > 0
  1046. ? COUNT_FORMATTER.format(props.node.children.length)
  1047. : null}
  1048. </ChildrenButton>
  1049. ) : null}
  1050. </div>
  1051. <Placeholder
  1052. className="Placeholder"
  1053. height="12px"
  1054. width={randomBetween(20, 80) + '%'}
  1055. style={{
  1056. transition: 'all 30s ease-out',
  1057. }}
  1058. />
  1059. </div>
  1060. </div>
  1061. <div
  1062. className={
  1063. props.index % 2 === 1 ? RIGHT_COLUMN_ODD_CLASSNAME : RIGHT_COLUMN_EVEN_CLASSNAME
  1064. }
  1065. style={{
  1066. width: props.manager.columns.span_list.width * 100 + '%',
  1067. }}
  1068. >
  1069. <Placeholder
  1070. className="Placeholder"
  1071. height="12px"
  1072. width={randomBetween(20, 80) + '%'}
  1073. style={{
  1074. transition: 'all 30s ease-out',
  1075. transform: `translate(${randomBetween(0, 200) + 'px'}, 0)`,
  1076. }}
  1077. />
  1078. </div>
  1079. </div>
  1080. );
  1081. }
  1082. function randomBetween(min: number, max: number) {
  1083. return Math.floor(Math.random() * (max - min + 1) + min);
  1084. }
  1085. function Connectors(props: {
  1086. manager: VirtualizedViewManager;
  1087. node: TraceTreeNode<TraceTree.NodeValue>;
  1088. }) {
  1089. const hasChildren =
  1090. (props.node.expanded || props.node.zoomedIn) && props.node.children.length > 0;
  1091. const showVerticalConnector =
  1092. hasChildren || (props.node.value && isParentAutogroupedNode(props.node));
  1093. // If the tail node of the collapsed node has no children,
  1094. // we don't want to render the vertical connector as no children
  1095. // are being rendered as the chain is entirely collapsed
  1096. const hideVerticalConnector =
  1097. showVerticalConnector &&
  1098. props.node.value &&
  1099. props.node instanceof ParentAutogroupNode &&
  1100. (!props.node.tail.children.length ||
  1101. (!props.node.tail.expanded && !props.node.expanded));
  1102. return (
  1103. <Fragment>
  1104. {props.node.connectors.map((c, i) => {
  1105. return (
  1106. <span
  1107. key={i}
  1108. style={{
  1109. left: -(
  1110. Math.abs(Math.abs(c) - props.node.depth) * props.manager.row_depth_padding
  1111. ),
  1112. }}
  1113. className={`TraceVerticalConnector ${c < 0 ? 'Orphaned' : ''}`}
  1114. />
  1115. );
  1116. })}
  1117. {showVerticalConnector && !hideVerticalConnector ? (
  1118. <span className="TraceExpandedVerticalConnector" />
  1119. ) : null}
  1120. {props.node.isLastChild ? (
  1121. <span className="TraceVerticalLastChildConnector" />
  1122. ) : (
  1123. <span className="TraceVerticalConnector" />
  1124. )}
  1125. </Fragment>
  1126. );
  1127. }
  1128. function ChildrenButton(props: {
  1129. children: React.ReactNode;
  1130. expanded: boolean;
  1131. icon: React.ReactNode;
  1132. onClick: (e: React.MouseEvent) => void;
  1133. status: TraceTreeNode<any>['fetchStatus'] | undefined;
  1134. }) {
  1135. return (
  1136. <button className={`TraceChildrenCount`} onClick={props.onClick}>
  1137. <div className="TraceChildrenCountContent">{props.children}</div>
  1138. <div className="TraceChildrenCountAction">
  1139. {props.icon}
  1140. {props.status === 'loading' ? (
  1141. <LoadingIndicator className="TraceActionsLoadingIndicator" size={8} />
  1142. ) : null}
  1143. </div>
  1144. </button>
  1145. );
  1146. }
  1147. interface TraceBarProps {
  1148. color: string;
  1149. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1150. manager: VirtualizedViewManager;
  1151. node_space: [number, number] | null;
  1152. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1153. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1154. virtualized_index: number;
  1155. }
  1156. function TraceBar(props: TraceBarProps) {
  1157. const duration = props.node_space ? formatTraceDuration(props.node_space[1]) : null;
  1158. const registerSpanBarRef = useCallback(
  1159. (ref: HTMLDivElement | null) => {
  1160. props.manager.registerSpanBarRef(
  1161. ref,
  1162. props.node_space!,
  1163. props.color,
  1164. props.virtualized_index
  1165. );
  1166. },
  1167. [props.manager, props.node_space, props.color, props.virtualized_index]
  1168. );
  1169. const registerSpanBarTextRef = useCallback(
  1170. (ref: HTMLDivElement | null) => {
  1171. props.manager.registerSpanBarTextRef(
  1172. ref,
  1173. duration!,
  1174. props.node_space!,
  1175. props.virtualized_index
  1176. );
  1177. },
  1178. [props.manager, props.node_space, props.virtualized_index, duration]
  1179. );
  1180. if (!props.node_space) {
  1181. return null;
  1182. }
  1183. return (
  1184. <Fragment>
  1185. <div ref={registerSpanBarRef} className="TraceBar">
  1186. {props.errors.size > 0 ? (
  1187. <ErrorIcons
  1188. node_space={props.node_space}
  1189. errors={props.errors}
  1190. manager={props.manager}
  1191. />
  1192. ) : null}
  1193. {props.performance_issues.size > 0 ? (
  1194. <PerformanceIssueIcons
  1195. node_space={props.node_space}
  1196. performance_issues={props.performance_issues}
  1197. manager={props.manager}
  1198. />
  1199. ) : null}
  1200. {props.performance_issues.size > 0 ||
  1201. props.errors.size > 0 ||
  1202. props.profiles.length > 0 ? (
  1203. <BackgroundPatterns
  1204. node_space={props.node_space}
  1205. performance_issues={props.performance_issues}
  1206. errors={props.errors}
  1207. manager={props.manager}
  1208. />
  1209. ) : null}
  1210. </div>
  1211. <div ref={registerSpanBarTextRef} className="TraceBarDuration">
  1212. {duration}
  1213. </div>
  1214. </Fragment>
  1215. );
  1216. }
  1217. interface MissingInstrumentationTraceBarProps {
  1218. color: string;
  1219. manager: VirtualizedViewManager;
  1220. node_space: [number, number] | null;
  1221. virtualized_index: number;
  1222. }
  1223. function MissingInstrumentationTraceBar(props: MissingInstrumentationTraceBarProps) {
  1224. const duration = props.node_space ? formatTraceDuration(props.node_space[1]) : null;
  1225. const registerSpanBarRef = useCallback(
  1226. (ref: HTMLDivElement | null) => {
  1227. props.manager.registerSpanBarRef(
  1228. ref,
  1229. props.node_space!,
  1230. props.color,
  1231. props.virtualized_index
  1232. );
  1233. },
  1234. [props.manager, props.node_space, props.color, props.virtualized_index]
  1235. );
  1236. const registerSpanBarTextRef = useCallback(
  1237. (ref: HTMLDivElement | null) => {
  1238. props.manager.registerSpanBarTextRef(
  1239. ref,
  1240. duration!,
  1241. props.node_space!,
  1242. props.virtualized_index
  1243. );
  1244. },
  1245. [props.manager, props.node_space, props.virtualized_index, duration]
  1246. );
  1247. return (
  1248. <div ref={registerSpanBarRef} className="TraceBar">
  1249. <div ref={registerSpanBarTextRef} className="TraceBarDuration">
  1250. {duration}
  1251. </div>
  1252. <div className="TracePatternContainer">
  1253. <div className="TracePattern missing_instrumentation" />
  1254. </div>
  1255. </div>
  1256. );
  1257. }
  1258. interface InvisibleTraceBarProps {
  1259. children: React.ReactNode;
  1260. manager: VirtualizedViewManager;
  1261. node_space: [number, number] | null;
  1262. virtualizedIndex: number;
  1263. }
  1264. function InvisibleTraceBar(props: InvisibleTraceBarProps) {
  1265. const registerInvisibleBarRef = useCallback(
  1266. (ref: HTMLDivElement | null) => {
  1267. props.manager.registerInvisibleBarRef(
  1268. ref,
  1269. props.node_space!,
  1270. props.virtualizedIndex
  1271. );
  1272. },
  1273. [props.manager, props.node_space, props.virtualizedIndex]
  1274. );
  1275. const onDoubleClick = useCallback(
  1276. (e: React.MouseEvent) => {
  1277. e.stopPropagation();
  1278. props.manager.onZoomIntoSpace(props.node_space!);
  1279. },
  1280. [props.manager, props.node_space]
  1281. );
  1282. if (!props.node_space || !props.children) {
  1283. return null;
  1284. }
  1285. return (
  1286. <div
  1287. ref={registerInvisibleBarRef}
  1288. onDoubleClick={onDoubleClick}
  1289. className="TraceBar Invisible"
  1290. >
  1291. {props.children}
  1292. </div>
  1293. );
  1294. }
  1295. interface BackgroundPatternsProps {
  1296. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1297. manager: VirtualizedViewManager;
  1298. node_space: [number, number] | null;
  1299. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1300. }
  1301. function BackgroundPatterns(props: BackgroundPatternsProps) {
  1302. const performance_issues = useMemo(() => {
  1303. if (!props.performance_issues.size) return [];
  1304. return [...props.performance_issues];
  1305. }, [props.performance_issues]);
  1306. const errors = useMemo(() => {
  1307. if (!props.errors.size) return [];
  1308. return [...props.errors];
  1309. }, [props.errors]);
  1310. const severity = useMemo(() => {
  1311. return getMaxErrorSeverity(errors);
  1312. }, [errors]);
  1313. if (!props.performance_issues.size && !props.errors.size) {
  1314. return null;
  1315. }
  1316. // If there is an error, render the error pattern across the entire width.
  1317. // Else if there is a performance issue, render the performance issue pattern
  1318. // for the duration of the performance issue. If there is a profile, render
  1319. // the profile pattern for entire duration (we do not have profile durations here)
  1320. return (
  1321. <Fragment>
  1322. {errors.length > 0 ? (
  1323. <div
  1324. className="TracePatternContainer"
  1325. style={{
  1326. left: 0,
  1327. width: '100%',
  1328. }}
  1329. >
  1330. <div className={`TracePattern ${severity}`} />
  1331. </div>
  1332. ) : performance_issues.length > 0 ? (
  1333. <Fragment>
  1334. {performance_issues.map((issue, i) => {
  1335. const timestamp = issue.start * 1e3;
  1336. // Clamp the issue timestamp to the span's timestamp
  1337. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1338. clamp(
  1339. timestamp,
  1340. props.node_space![0],
  1341. props.node_space![0] + props.node_space![1]
  1342. ),
  1343. props.node_space!
  1344. );
  1345. return (
  1346. <Fragment key={i}>
  1347. <div
  1348. className="TracePatternContainer"
  1349. style={{
  1350. left: left * 100 + '%',
  1351. width: (1 - left) * 100 + '%',
  1352. }}
  1353. >
  1354. <div className="TracePattern performance_issue" />
  1355. </div>
  1356. </Fragment>
  1357. );
  1358. })}
  1359. </Fragment>
  1360. ) : null}
  1361. </Fragment>
  1362. );
  1363. }
  1364. interface ErrorIconsProps {
  1365. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1366. manager: VirtualizedViewManager;
  1367. node_space: [number, number] | null;
  1368. }
  1369. function ErrorIcons(props: ErrorIconsProps) {
  1370. const errors = useMemo(() => {
  1371. return [...props.errors];
  1372. }, [props.errors]);
  1373. if (!props.errors.size) {
  1374. return null;
  1375. }
  1376. return (
  1377. <Fragment>
  1378. {errors.map((error, i) => {
  1379. const timestamp = error.timestamp ? error.timestamp * 1e3 : props.node_space![0];
  1380. // Clamp the error timestamp to the span's timestamp
  1381. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1382. clamp(
  1383. timestamp,
  1384. props.node_space![0],
  1385. props.node_space![0] + props.node_space![1]
  1386. ),
  1387. props.node_space!
  1388. );
  1389. return (
  1390. <div
  1391. key={i}
  1392. className={`TraceIcon ${error.level}`}
  1393. style={{left: left * 100 + '%'}}
  1394. >
  1395. <TraceIcons.Icon event={error} />
  1396. </div>
  1397. );
  1398. })}
  1399. </Fragment>
  1400. );
  1401. }
  1402. interface PerformanceIssueIconsProps {
  1403. manager: VirtualizedViewManager;
  1404. node_space: [number, number] | null;
  1405. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1406. }
  1407. function PerformanceIssueIcons(props: PerformanceIssueIconsProps) {
  1408. const performance_issues = useMemo(() => {
  1409. return [...props.performance_issues];
  1410. }, [props.performance_issues]);
  1411. if (!props.performance_issues.size) {
  1412. return null;
  1413. }
  1414. return (
  1415. <Fragment>
  1416. {performance_issues.map((issue, i) => {
  1417. const timestamp = issue.timestamp
  1418. ? issue.timestamp * 1e3
  1419. : issue.start
  1420. ? issue.start * 1e3
  1421. : props.node_space![0];
  1422. // Clamp the issue timestamp to the span's timestamp
  1423. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1424. clamp(
  1425. timestamp,
  1426. props.node_space![0],
  1427. props.node_space![0] + props.node_space![1]
  1428. ),
  1429. props.node_space!
  1430. );
  1431. return (
  1432. <div
  1433. key={i}
  1434. className={`TraceIcon performance_issue`}
  1435. style={{left: left * 100 + '%'}}
  1436. >
  1437. <TraceIcons.Icon event={issue} />
  1438. </div>
  1439. );
  1440. })}
  1441. </Fragment>
  1442. );
  1443. }
  1444. interface AutogroupedTraceBarProps {
  1445. color: string;
  1446. entire_space: [number, number] | null;
  1447. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1448. manager: VirtualizedViewManager;
  1449. node_spaces: [number, number][];
  1450. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1451. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1452. virtualized_index: number;
  1453. }
  1454. function AutogroupedTraceBar(props: AutogroupedTraceBarProps) {
  1455. const duration = props.entire_space ? formatTraceDuration(props.entire_space[1]) : null;
  1456. const registerInvisibleBarRef = useCallback(
  1457. (ref: HTMLDivElement | null) => {
  1458. props.manager.registerInvisibleBarRef(
  1459. ref,
  1460. props.entire_space!,
  1461. props.virtualized_index
  1462. );
  1463. },
  1464. [props.manager, props.entire_space, props.virtualized_index]
  1465. );
  1466. const registerAutogroupedSpanBarTextRef = useCallback(
  1467. (ref: HTMLDivElement | null) => {
  1468. props.manager.registerSpanBarTextRef(
  1469. ref,
  1470. duration!,
  1471. props.entire_space!,
  1472. props.virtualized_index
  1473. );
  1474. },
  1475. [props.manager, props.entire_space, props.virtualized_index, duration]
  1476. );
  1477. if (props.node_spaces && props.node_spaces.length <= 1) {
  1478. return (
  1479. <TraceBar
  1480. color={props.color}
  1481. node_space={props.entire_space}
  1482. manager={props.manager}
  1483. virtualized_index={props.virtualized_index}
  1484. errors={props.errors}
  1485. performance_issues={props.performance_issues}
  1486. profiles={props.profiles}
  1487. />
  1488. );
  1489. }
  1490. if (!props.node_spaces || !props.entire_space) {
  1491. return null;
  1492. }
  1493. return (
  1494. <Fragment>
  1495. <div ref={registerInvisibleBarRef} className="TraceBar Invisible">
  1496. {props.node_spaces.map((node_space, i) => {
  1497. const width = node_space[1] / props.entire_space![1];
  1498. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1499. node_space[0],
  1500. props.entire_space!
  1501. );
  1502. return (
  1503. <div
  1504. key={i}
  1505. className="TraceBar"
  1506. style={{
  1507. left: `${left * 100}%`,
  1508. width: `${width * 100}%`,
  1509. backgroundColor: props.color,
  1510. }}
  1511. />
  1512. );
  1513. })}
  1514. {/* Autogrouped bars only render icons. That is because in the case of multiple bars
  1515. with tiny gaps, the background pattern looks broken as it does not repeat nicely */}
  1516. {props.errors.size > 0 ? (
  1517. <ErrorIcons
  1518. node_space={props.entire_space}
  1519. errors={props.errors}
  1520. manager={props.manager}
  1521. />
  1522. ) : null}
  1523. {props.performance_issues.size > 0 ? (
  1524. <PerformanceIssueIcons
  1525. node_space={props.entire_space}
  1526. performance_issues={props.performance_issues}
  1527. manager={props.manager}
  1528. />
  1529. ) : null}
  1530. </div>
  1531. <div ref={registerAutogroupedSpanBarTextRef} className="TraceBarDuration">
  1532. {duration}
  1533. </div>
  1534. </Fragment>
  1535. );
  1536. }
  1537. /**
  1538. * This is a wrapper around the Trace component to apply styles
  1539. * to the trace tree. It exists because we _do not_ want to trigger
  1540. * emotion's css parsing logic as it is very slow and will cause
  1541. * the scrolling to flicker.
  1542. */
  1543. const TraceStylingWrapper = styled('div')`
  1544. margin: auto;
  1545. overscroll-behavior: none;
  1546. box-shadow: 0 0 0 1px ${p => p.theme.border};
  1547. position: absolute;
  1548. left: 0;
  1549. top: 0;
  1550. width: 100%;
  1551. height: 100%;
  1552. grid-area: trace;
  1553. padding-top: 26px;
  1554. &.WithIndicators {
  1555. padding-top: 44px;
  1556. &:before {
  1557. height: 44px;
  1558. .TraceScrollbarContainer {
  1559. height: 44px;
  1560. }
  1561. }
  1562. .TraceIndicator.Timeline {
  1563. .TraceIndicatorLabel {
  1564. top: 26px;
  1565. }
  1566. .TraceIndicatorLine {
  1567. top: 30px;
  1568. }
  1569. }
  1570. }
  1571. &:before {
  1572. content: '';
  1573. position: absolute;
  1574. left: 0;
  1575. top: 0;
  1576. width: 100%;
  1577. height: 26px;
  1578. background-color: ${p => p.theme.backgroundSecondary};
  1579. border-bottom: 1px solid ${p => p.theme.border};
  1580. }
  1581. &.Loading {
  1582. .TraceRow {
  1583. .TraceLeftColumnInner {
  1584. width: 100%;
  1585. }
  1586. }
  1587. .TraceRightColumn {
  1588. background-color: transparent !important;
  1589. }
  1590. .TraceDivider {
  1591. pointer-events: none;
  1592. }
  1593. }
  1594. &.Empty {
  1595. .TraceIcon {
  1596. left: 50%;
  1597. }
  1598. }
  1599. .TraceScrollbarContainer {
  1600. left: 0;
  1601. top: 0;
  1602. height: 26px;
  1603. position: absolute;
  1604. overflow-x: auto;
  1605. overscroll-behavior: none;
  1606. will-change: transform;
  1607. .TraceScrollbarScroller {
  1608. height: 1px;
  1609. pointer-events: none;
  1610. visibility: hidden;
  1611. }
  1612. .TraceScrollbarHandle {
  1613. width: 24px;
  1614. height: 12px;
  1615. border-radius: 6px;
  1616. }
  1617. }
  1618. .TraceDivider {
  1619. position: absolute;
  1620. height: 100%;
  1621. background-color: transparent;
  1622. top: 0;
  1623. cursor: ew-resize;
  1624. z-index: 10;
  1625. &:before {
  1626. content: '';
  1627. position: absolute;
  1628. width: 1px;
  1629. height: 100%;
  1630. background-color: ${p => p.theme.border};
  1631. left: 50%;
  1632. }
  1633. &:hover {
  1634. &:before {
  1635. background-color: ${p => p.theme.purple300};
  1636. }
  1637. }
  1638. }
  1639. .TraceIndicatorContainer {
  1640. overflow: hidden;
  1641. width: 100%;
  1642. height: 100%;
  1643. position: absolute;
  1644. right: 0;
  1645. top: 0;
  1646. z-index: 10;
  1647. pointer-events: none;
  1648. }
  1649. .TraceIndicator {
  1650. z-index: 1;
  1651. width: 3px;
  1652. height: 100%;
  1653. top: 0;
  1654. position: absolute;
  1655. &:hover {
  1656. z-index: 10;
  1657. }
  1658. .TraceIndicatorLabel {
  1659. min-width: 34px;
  1660. text-align: center;
  1661. position: absolute;
  1662. font-size: 10px;
  1663. font-weight: bold;
  1664. color: ${p => p.theme.textColor};
  1665. background-color: ${p => p.theme.background};
  1666. border-radius: ${p => p.theme.borderRadius};
  1667. border: 1px solid ${p => p.theme.border};
  1668. padding: 2px;
  1669. display: inline-block;
  1670. line-height: 1;
  1671. margin-top: 2px;
  1672. white-space: nowrap;
  1673. }
  1674. .TraceIndicatorLine {
  1675. width: 1px;
  1676. height: 100%;
  1677. top: 20px;
  1678. position: absolute;
  1679. left: 50%;
  1680. transform: translateX(-2px);
  1681. background: repeating-linear-gradient(
  1682. to bottom,
  1683. transparent 0 4px,
  1684. ${p => p.theme.textColor} 4px 8px
  1685. )
  1686. 80%/2px 100% no-repeat;
  1687. }
  1688. &.Errored {
  1689. .TraceIndicatorLabel {
  1690. border: 1px solid ${p => p.theme.error};
  1691. color: ${p => p.theme.error};
  1692. }
  1693. .TraceIndicatorLine {
  1694. background: repeating-linear-gradient(
  1695. to bottom,
  1696. transparent 0 4px,
  1697. ${p => p.theme.error} 4px 8px
  1698. )
  1699. 80%/2px 100% no-repeat;
  1700. }
  1701. }
  1702. &.Timeline {
  1703. opacity: 1;
  1704. z-index: 1;
  1705. pointer-events: none;
  1706. .TraceIndicatorLabel {
  1707. font-weight: normal;
  1708. min-width: 0;
  1709. top: 8px;
  1710. width: auto;
  1711. border: none;
  1712. background-color: transparent;
  1713. color: ${p => p.theme.subText};
  1714. }
  1715. .TraceIndicatorLine {
  1716. background: ${p => p.theme.translucentGray100};
  1717. top: 8px;
  1718. }
  1719. }
  1720. }
  1721. &.light {
  1722. .TracePattern {
  1723. &.info {
  1724. --pattern-odd: #d1dff9;
  1725. --pattern-even: ${p => p.theme.blue300};
  1726. }
  1727. &.warning {
  1728. --pattern-odd: #a5752c;
  1729. --pattern-even: ${p => p.theme.yellow300};
  1730. }
  1731. &.performance_issue {
  1732. --pattern-odd: #063690;
  1733. --pattern-even: ${p => p.theme.blue300};
  1734. }
  1735. &.profile {
  1736. --pattern-odd: rgba(58, 17, 95, 0.55);
  1737. --pattern-even: transparent;
  1738. }
  1739. &.missing_instrumentation {
  1740. --pattern-odd: #4b4550;
  1741. --pattern-even: rgb(128, 112, 143);
  1742. }
  1743. &.error,
  1744. &.fatal {
  1745. --pattern-odd: #872d32;
  1746. --pattern-even: ${p => p.theme.red300};
  1747. }
  1748. /* false positive for grid layout */
  1749. /* stylelint-disable */
  1750. &.default {
  1751. }
  1752. &.unknown {
  1753. }
  1754. /* stylelint-enable */
  1755. }
  1756. }
  1757. &.dark {
  1758. .TracePattern {
  1759. &.info {
  1760. --pattern-odd: #d1dff9;
  1761. --pattern-even: ${p => p.theme.blue300};
  1762. }
  1763. &.warning {
  1764. --pattern-odd: #a5752c;
  1765. --pattern-even: ${p => p.theme.yellow300};
  1766. }
  1767. &.performance_issue {
  1768. --pattern-odd: #063690;
  1769. --pattern-even: ${p => p.theme.blue300};
  1770. }
  1771. &.profile {
  1772. --pattern-odd: rgba(58, 17, 95, 0.55);
  1773. --pattern-even: transparent;
  1774. }
  1775. &.missing_instrumentation {
  1776. --pattern-odd: #4b4550;
  1777. --pattern-even: #1c1521;
  1778. }
  1779. &.error,
  1780. &.fatal {
  1781. --pattern-odd: #510d10;
  1782. --pattern-even: ${p => p.theme.red300};
  1783. }
  1784. /* stylelint-disable */
  1785. &.default {
  1786. }
  1787. &.unknown {
  1788. }
  1789. /* stylelint-enable */
  1790. }
  1791. }
  1792. .TraceRow {
  1793. display: flex;
  1794. align-items: center;
  1795. position: absolute;
  1796. height: 24px;
  1797. width: 100%;
  1798. transition: none;
  1799. font-size: ${p => p.theme.fontSizeSmall};
  1800. transform: translateZ(0);
  1801. --row-background-odd: ${p => p.theme.translucentSurface100};
  1802. --row-background-hover: ${p => p.theme.translucentSurface100};
  1803. --row-background-focused: ${p => p.theme.translucentSurface200};
  1804. --row-outline: ${p => p.theme.blue300};
  1805. --row-children-button-border-color: ${p => p.theme.border};
  1806. /* allow empty blocks so we can keep an exhaustive list of classnames for future reference */
  1807. /* stylelint-disable */
  1808. &.info {
  1809. }
  1810. &.warning {
  1811. }
  1812. &.error,
  1813. &.fatal,
  1814. &.performance_issue {
  1815. color: ${p => p.theme.errorText};
  1816. --autogrouped: ${p => p.theme.error};
  1817. --row-children-button-border-color: ${p => p.theme.error};
  1818. --row-outline: ${p => p.theme.error};
  1819. }
  1820. &.default {
  1821. }
  1822. &.unknown {
  1823. }
  1824. &.Hidden {
  1825. position: absolute;
  1826. height: 100%;
  1827. width: 100%;
  1828. top: 0;
  1829. z-index: -1;
  1830. &:hover {
  1831. background-color: transparent;
  1832. }
  1833. * {
  1834. cursor: default !important;
  1835. }
  1836. }
  1837. .TraceIcon {
  1838. position: absolute;
  1839. top: 50%;
  1840. transform: translate(-50%, -50%) scaleX(var(--inverse-span-scale)) translateZ(0);
  1841. background-color: ${p => p.theme.background};
  1842. width: 18px !important;
  1843. height: 18px !important;
  1844. border-radius: 50%;
  1845. display: flex;
  1846. align-items: center;
  1847. justify-content: center;
  1848. z-index: 1;
  1849. &.info {
  1850. background-color: var(--info);
  1851. }
  1852. &.warning {
  1853. background-color: var(--warning);
  1854. }
  1855. &.error,
  1856. &.fatal {
  1857. background-color: var(--error);
  1858. }
  1859. &.performance_issue {
  1860. background-color: var(--performance-issue);
  1861. }
  1862. &.default {
  1863. background-color: var(--default);
  1864. }
  1865. &.unknown {
  1866. background-color: var(--unknown);
  1867. }
  1868. &.profile {
  1869. background-color: var(--profile);
  1870. }
  1871. svg {
  1872. width: 12px;
  1873. height: 12px;
  1874. fill: ${p => p.theme.white};
  1875. }
  1876. &.profile svg {
  1877. margin-left: 2px;
  1878. }
  1879. &.info,
  1880. &.warning,
  1881. &.performance_issue,
  1882. &.default,
  1883. &.unknown {
  1884. svg {
  1885. transform: translateY(-1px);
  1886. }
  1887. }
  1888. }
  1889. .TracePatternContainer {
  1890. position: absolute;
  1891. width: 100%;
  1892. height: 100%;
  1893. overflow: hidden;
  1894. }
  1895. .TracePattern {
  1896. left: 0;
  1897. width: 1000000px;
  1898. height: 100%;
  1899. position: absolute;
  1900. transform-origin: left center;
  1901. transform: scaleX(var(--inverse-span-scale)) translateZ(0);
  1902. background-image: linear-gradient(
  1903. 135deg,
  1904. var(--pattern-even) 1%,
  1905. var(--pattern-even) 11%,
  1906. var(--pattern-odd) 11%,
  1907. var(--pattern-odd) 21%,
  1908. var(--pattern-even) 21%,
  1909. var(--pattern-even) 31%,
  1910. var(--pattern-odd) 31%,
  1911. var(--pattern-odd) 41%,
  1912. var(--pattern-even) 41%,
  1913. var(--pattern-even) 51%,
  1914. var(--pattern-odd) 51%,
  1915. var(--pattern-odd) 61%,
  1916. var(--pattern-even) 61%,
  1917. var(--pattern-even) 71%,
  1918. var(--pattern-odd) 71%,
  1919. var(--pattern-odd) 81%,
  1920. var(--pattern-even) 81%,
  1921. var(--pattern-even) 91%,
  1922. var(--pattern-odd) 91%,
  1923. var(--pattern-odd) 101%
  1924. );
  1925. background-size: 25.5px 17px;
  1926. }
  1927. .TracePerformanceIssue {
  1928. position: absolute;
  1929. top: 0;
  1930. display: flex;
  1931. align-items: center;
  1932. justify-content: flex-start;
  1933. background-color: var(--performance-issue);
  1934. height: 16px;
  1935. }
  1936. .TraceRightColumn.Odd {
  1937. background-color: var(--row-background-odd);
  1938. }
  1939. &:hover {
  1940. background-color: var(--row-background-hovered);
  1941. }
  1942. &.Highlight {
  1943. box-shadow: inset 0 0 0 1px ${p => p.theme.blue200} !important;
  1944. .TraceLeftColumn {
  1945. box-shadow: inset 0px 0 0px 1px ${p => p.theme.blue200} !important;
  1946. }
  1947. }
  1948. &.Highlight,
  1949. &:focus,
  1950. &[tabindex='0'] {
  1951. outline: none;
  1952. background-color: var(--row-background-focused);
  1953. .TraceRightColumn.Odd {
  1954. background-color: transparent !important;
  1955. }
  1956. }
  1957. &:focus,
  1958. &[tabindex='0'] {
  1959. background-color: var(--row-background-focused);
  1960. box-shadow: inset 0 0 0 1px var(--row-outline) !important;
  1961. .TraceLeftColumn {
  1962. box-shadow: inset 0px 0 0px 1px var(--row-outline) !important;
  1963. }
  1964. .TraceRightColumn.Odd {
  1965. background-color: transparent !important;
  1966. }
  1967. }
  1968. &.SearchResult {
  1969. background-color: ${p => p.theme.yellow100};
  1970. .TraceRightColumn {
  1971. background-color: transparent;
  1972. }
  1973. }
  1974. &.Autogrouped {
  1975. color: ${p => p.theme.blue300};
  1976. .TraceDescription {
  1977. font-weight: bold;
  1978. }
  1979. .TraceChildrenCountWrapper {
  1980. button {
  1981. color: ${p => p.theme.white};
  1982. background-color: ${p => p.theme.blue300};
  1983. }
  1984. svg {
  1985. fill: ${p => p.theme.white};
  1986. }
  1987. }
  1988. }
  1989. }
  1990. .TraceLeftColumn {
  1991. height: 100%;
  1992. white-space: nowrap;
  1993. display: flex;
  1994. align-items: center;
  1995. overflow: hidden;
  1996. will-change: width;
  1997. box-shadow: inset 1px 0 0px 0px transparent;
  1998. cursor: pointer;
  1999. width: calc(var(--list-column-width) * 100%);
  2000. .TraceLeftColumnInner {
  2001. height: 100%;
  2002. white-space: nowrap;
  2003. display: flex;
  2004. align-items: center;
  2005. will-change: transform;
  2006. transform-origin: left center;
  2007. padding-right: ${space(2)};
  2008. img {
  2009. width: 16px;
  2010. height: 16px;
  2011. }
  2012. }
  2013. }
  2014. .TraceRightColumn {
  2015. height: 100%;
  2016. overflow: hidden;
  2017. position: relative;
  2018. display: flex;
  2019. align-items: center;
  2020. will-change: width;
  2021. z-index: 1;
  2022. cursor: pointer;
  2023. width: calc(var(--span-column-width) * 100%);
  2024. &:hover {
  2025. .TraceArrow.Visible {
  2026. opacity: 1;
  2027. transition: 300ms 300ms ease-out;
  2028. pointer-events: auto;
  2029. }
  2030. }
  2031. }
  2032. .TraceBar {
  2033. position: absolute;
  2034. height: 16px;
  2035. width: 100%;
  2036. background-color: black;
  2037. transform-origin: left center;
  2038. &.Invisible {
  2039. background-color: transparent !important;
  2040. > div {
  2041. height: 100%;
  2042. }
  2043. }
  2044. svg {
  2045. width: 14px;
  2046. height: 14px;
  2047. }
  2048. }
  2049. .TraceArrow {
  2050. position: absolute;
  2051. pointer-events: none;
  2052. top: 0;
  2053. width: 14px;
  2054. height: 24px;
  2055. opacity: 0;
  2056. background-color: transparent;
  2057. border: none;
  2058. transition: 60ms ease-out;
  2059. font-size: ${p => p.theme.fontSizeMedium};
  2060. color: ${p => p.theme.subText};
  2061. padding: 0 2px;
  2062. display: flex;
  2063. align-items: center;
  2064. svg {
  2065. fill: ${p => p.theme.subText};
  2066. }
  2067. &.Left {
  2068. left: 0;
  2069. }
  2070. &.Right {
  2071. right: 0;
  2072. transform: rotate(180deg);
  2073. }
  2074. }
  2075. .TraceBarDuration {
  2076. display: inline-block;
  2077. transform-origin: left center;
  2078. font-size: ${p => p.theme.fontSizeExtraSmall};
  2079. color: ${p => p.theme.gray300};
  2080. white-space: nowrap;
  2081. font-variant-numeric: tabular-nums;
  2082. position: absolute;
  2083. }
  2084. .TraceChildrenCount {
  2085. height: 16px;
  2086. white-space: nowrap;
  2087. min-width: 30px;
  2088. display: flex;
  2089. align-items: center;
  2090. justify-content: center;
  2091. border-radius: 99px;
  2092. padding: 0px 4px;
  2093. transition: all 0.15s ease-in-out;
  2094. background: ${p => p.theme.background};
  2095. border: 1.5px solid var(--row-children-button-border-color);
  2096. line-height: 0;
  2097. z-index: 1;
  2098. font-size: 10px;
  2099. box-shadow: ${p => p.theme.dropShadowLight};
  2100. margin-right: 8px;
  2101. .TraceChildrenCountContent {
  2102. + .TraceChildrenCountAction {
  2103. margin-left: 2px;
  2104. }
  2105. }
  2106. .TraceChildrenCountAction {
  2107. position: relative;
  2108. display: flex;
  2109. align-items: center;
  2110. justify-content: center;
  2111. }
  2112. .TraceActionsLoadingIndicator {
  2113. margin: 0;
  2114. position: absolute;
  2115. top: 50%;
  2116. left: 50%;
  2117. transform: translate(-50%, -50%);
  2118. background-color: ${p => p.theme.background};
  2119. animation: show 0.1s ease-in-out forwards;
  2120. @keyframes show {
  2121. from {
  2122. opacity: 0;
  2123. transform: translate(-50%, -50%) scale(0.86);
  2124. }
  2125. to {
  2126. opacity: 1;
  2127. transform: translate(-50%, -50%) scale(1);
  2128. }
  2129. }
  2130. .loading-indicator {
  2131. border-width: 2px;
  2132. }
  2133. .loading-message {
  2134. display: none;
  2135. }
  2136. }
  2137. svg {
  2138. width: 7px;
  2139. transition: none;
  2140. }
  2141. }
  2142. .TraceChildrenCountWrapper {
  2143. display: flex;
  2144. justify-content: flex-end;
  2145. align-items: center;
  2146. min-width: 44px;
  2147. height: 100%;
  2148. position: relative;
  2149. button {
  2150. transition: none;
  2151. }
  2152. svg {
  2153. fill: currentColor;
  2154. }
  2155. &.Orphaned {
  2156. .TraceVerticalConnector,
  2157. .TraceVerticalLastChildConnector,
  2158. .TraceExpandedVerticalConnector {
  2159. border-left: 2px dashed ${p => p.theme.border};
  2160. }
  2161. &::before {
  2162. border-bottom: 2px dashed ${p => p.theme.border};
  2163. }
  2164. }
  2165. &.Root {
  2166. &:before,
  2167. .TraceVerticalLastChildConnector {
  2168. visibility: hidden;
  2169. }
  2170. }
  2171. &::before {
  2172. content: '';
  2173. display: block;
  2174. width: 50%;
  2175. height: 2px;
  2176. border-bottom: 2px solid ${p => p.theme.border};
  2177. position: absolute;
  2178. left: 0;
  2179. top: 50%;
  2180. transform: translateY(-50%);
  2181. }
  2182. &::after {
  2183. content: '';
  2184. background-color: ${p => p.theme.border};
  2185. border-radius: 50%;
  2186. height: 6px;
  2187. width: 6px;
  2188. position: absolute;
  2189. left: 50%;
  2190. top: 50%;
  2191. transform: translateY(-50%);
  2192. }
  2193. }
  2194. .TraceVerticalConnector {
  2195. position: absolute;
  2196. left: 0;
  2197. top: 0;
  2198. bottom: 0;
  2199. height: 100%;
  2200. width: 2px;
  2201. border-left: 2px solid ${p => p.theme.border};
  2202. &.Orphaned {
  2203. border-left: 2px dashed ${p => p.theme.border};
  2204. }
  2205. }
  2206. .TraceVerticalLastChildConnector {
  2207. position: absolute;
  2208. left: 0;
  2209. top: 0;
  2210. bottom: 0;
  2211. height: 50%;
  2212. width: 2px;
  2213. border-left: 2px solid ${p => p.theme.border};
  2214. border-bottom-left-radius: 4px;
  2215. }
  2216. .TraceExpandedVerticalConnector {
  2217. position: absolute;
  2218. bottom: 0;
  2219. height: 50%;
  2220. left: 50%;
  2221. width: 2px;
  2222. border-left: 2px solid ${p => p.theme.border};
  2223. }
  2224. .TraceOperation {
  2225. margin-left: 4px;
  2226. text-overflow: ellipsis;
  2227. white-space: nowrap;
  2228. font-weight: bold;
  2229. }
  2230. .TraceEmDash {
  2231. margin-left: 4px;
  2232. margin-right: 4px;
  2233. }
  2234. .TraceDescription {
  2235. white-space: nowrap;
  2236. }
  2237. `;