trace.tsx 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538
  1. import type React from 'react';
  2. import {
  3. Fragment,
  4. useCallback,
  5. useEffect,
  6. useLayoutEffect,
  7. useMemo,
  8. useRef,
  9. useState,
  10. } from 'react';
  11. import {type Theme, useTheme} from '@emotion/react';
  12. import styled from '@emotion/styled';
  13. import * as Sentry from '@sentry/react';
  14. import {PlatformIcon} from 'platformicons';
  15. import LoadingIndicator from 'sentry/components/loadingIndicator';
  16. import Placeholder from 'sentry/components/placeholder';
  17. import {replayPlayerTimestampEmitter} from 'sentry/components/replays/replayContext';
  18. import {t, tct} from 'sentry/locale';
  19. import ConfigStore from 'sentry/stores/configStore';
  20. import {space} from 'sentry/styles/space';
  21. import type {Organization, PlatformKey, Project} from 'sentry/types';
  22. import {trackAnalytics} from 'sentry/utils/analytics';
  23. import {formatTraceDuration} from 'sentry/utils/duration/formatTraceDuration';
  24. import type {
  25. TraceError,
  26. TracePerformanceIssue,
  27. } from 'sentry/utils/performance/quickTrace/types';
  28. import {clamp} from 'sentry/utils/profiling/colors/utils';
  29. import useApi from 'sentry/utils/useApi';
  30. import useOrganization from 'sentry/utils/useOrganization';
  31. import useProjects from 'sentry/utils/useProjects';
  32. import {
  33. useVirtualizedList,
  34. type VirtualizedRow,
  35. } from 'sentry/views/performance/newTraceDetails/traceRenderers/traceVirtualizedList';
  36. import type {VirtualizedViewManager} from 'sentry/views/performance/newTraceDetails/traceRenderers/virtualizedViewManager';
  37. import type {TraceReducerState} from 'sentry/views/performance/newTraceDetails/traceState';
  38. import {
  39. getRovingIndexActionFromDOMEvent,
  40. type RovingTabIndexUserActions,
  41. } from 'sentry/views/performance/newTraceDetails/traceState/traceRovingTabIndex';
  42. import {
  43. makeTraceNodeBarColor,
  44. ParentAutogroupNode,
  45. TraceTree,
  46. type TraceTreeNode,
  47. } from './traceModels/traceTree';
  48. import {useTraceState, useTraceStateDispatch} from './traceState/traceStateProvider';
  49. import {
  50. isAutogroupedNode,
  51. isMissingInstrumentationNode,
  52. isNoDataNode,
  53. isParentAutogroupedNode,
  54. isSpanNode,
  55. isTraceErrorNode,
  56. isTraceNode,
  57. isTransactionNode,
  58. } from './guards';
  59. import {TraceIcons} from './icons';
  60. const COUNT_FORMATTER = Intl.NumberFormat(undefined, {notation: 'compact'});
  61. const NO_ERRORS = new Set<TraceError>();
  62. const NO_PERFORMANCE_ISSUES = new Set<TracePerformanceIssue>();
  63. const NO_PROFILES = [];
  64. function computeNextIndexFromAction(
  65. current_index: number,
  66. action: RovingTabIndexUserActions,
  67. items: number
  68. ): number {
  69. switch (action) {
  70. case 'next':
  71. if (current_index === items) {
  72. return 0;
  73. }
  74. return current_index + 1;
  75. case 'previous':
  76. if (current_index === 0) {
  77. return items;
  78. }
  79. return current_index - 1;
  80. case 'last':
  81. return items;
  82. case 'first':
  83. return 0;
  84. default:
  85. throw new TypeError(`Invalid or not implemented reducer action - ${action}`);
  86. }
  87. }
  88. function getMaxErrorSeverity(errors: TraceTree.TraceError[]) {
  89. return errors.reduce((acc, error) => {
  90. if (error.level === 'fatal') {
  91. return 'fatal';
  92. }
  93. if (error.level === 'error') {
  94. return acc === 'fatal' ? 'fatal' : 'error';
  95. }
  96. if (error.level === 'warning') {
  97. return acc === 'fatal' || acc === 'error' ? acc : 'warning';
  98. }
  99. return acc;
  100. }, 'default');
  101. }
  102. const RIGHT_COLUMN_EVEN_CLASSNAME = `TraceRightColumn`;
  103. const RIGHT_COLUMN_ODD_CLASSNAME = [RIGHT_COLUMN_EVEN_CLASSNAME, 'Odd'].join(' ');
  104. const CHILDREN_COUNT_WRAPPER_CLASSNAME = `TraceChildrenCountWrapper`;
  105. const CHILDREN_COUNT_WRAPPER_ORPHANED_CLASSNAME = [
  106. CHILDREN_COUNT_WRAPPER_CLASSNAME,
  107. 'Orphaned',
  108. ].join(' ');
  109. const ERROR_LEVEL_LABELS: Record<keyof Theme['level'], string> = {
  110. sample: t('Sample'),
  111. info: t('Info'),
  112. warning: t('Warning'),
  113. // Hardcoded legacy color (orange400). We no longer use orange anywhere
  114. // else in the app (except for the chart palette). This needs to be harcoded
  115. // here because existing users may still associate orange with the "error" level.
  116. error: t('Error'),
  117. fatal: t('Fatal'),
  118. default: t('Default'),
  119. unknown: t('Unknown'),
  120. };
  121. function maybeFocusRow(
  122. ref: HTMLDivElement | null,
  123. node: TraceTreeNode<TraceTree.NodeValue>,
  124. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>
  125. ) {
  126. if (!ref) return;
  127. if (node === previouslyFocusedNodeRef.current) return;
  128. previouslyFocusedNodeRef.current = node;
  129. ref.focus();
  130. }
  131. interface TraceProps {
  132. forceRerender: number;
  133. initializedRef: React.MutableRefObject<boolean>;
  134. manager: VirtualizedViewManager;
  135. onRowClick: (
  136. node: TraceTreeNode<TraceTree.NodeValue>,
  137. event: React.MouseEvent<HTMLElement>,
  138. index: number
  139. ) => void;
  140. onTraceLoad: (
  141. trace: TraceTree,
  142. node: TraceTreeNode<TraceTree.NodeValue> | null,
  143. index: number | null
  144. ) => void;
  145. onTraceSearch: (
  146. query: string,
  147. node: TraceTreeNode<TraceTree.NodeValue>,
  148. behavior: 'track result' | 'persist'
  149. ) => void;
  150. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>;
  151. rerender: () => void;
  152. scrollQueueRef: React.MutableRefObject<
  153. | {
  154. eventId?: string;
  155. path?: TraceTree.NodePath[];
  156. }
  157. | null
  158. | undefined
  159. >;
  160. trace: TraceTree;
  161. trace_id: string;
  162. }
  163. export function Trace({
  164. trace,
  165. trace_id,
  166. onRowClick,
  167. manager,
  168. scrollQueueRef,
  169. previouslyFocusedNodeRef,
  170. onTraceSearch,
  171. onTraceLoad,
  172. rerender,
  173. initializedRef,
  174. forceRerender,
  175. }: TraceProps) {
  176. const theme = useTheme();
  177. const api = useApi();
  178. const {projects} = useProjects();
  179. const organization = useOrganization();
  180. const traceState = useTraceState();
  181. const traceDispatch = useTraceStateDispatch();
  182. const rerenderRef = useRef<TraceProps['rerender']>(rerender);
  183. rerenderRef.current = rerender;
  184. const treePromiseStatusRef =
  185. useRef<Map<TraceTreeNode<TraceTree.NodeValue>, 'loading' | 'error' | 'success'>>();
  186. if (!treePromiseStatusRef.current) {
  187. treePromiseStatusRef.current = new Map();
  188. }
  189. const treeRef = useRef<TraceTree>(trace);
  190. treeRef.current = trace;
  191. const traceStateRef = useRef<TraceReducerState>(traceState);
  192. traceStateRef.current = traceState;
  193. useLayoutEffect(() => {
  194. if (initializedRef.current) {
  195. return;
  196. }
  197. if (trace.type !== 'trace' || !manager) {
  198. return;
  199. }
  200. initializedRef.current = true;
  201. if (!scrollQueueRef.current) {
  202. onTraceLoad(trace, null, null);
  203. return;
  204. }
  205. // Node path has higher specificity than eventId
  206. const promise = scrollQueueRef.current?.path
  207. ? TraceTree.ExpandToPath(trace, scrollQueueRef.current.path, rerenderRef.current, {
  208. api,
  209. organization,
  210. })
  211. : scrollQueueRef.current.eventId
  212. ? TraceTree.ExpandToEventID(
  213. scrollQueueRef?.current?.eventId,
  214. trace,
  215. rerenderRef.current,
  216. {
  217. api,
  218. organization,
  219. }
  220. )
  221. : Promise.resolve(null);
  222. promise
  223. .then(maybeNode => {
  224. onTraceLoad(trace, maybeNode?.node ?? null, maybeNode?.index ?? null);
  225. if (!maybeNode) {
  226. Sentry.captureMessage('Failed to find and scroll to node in tree');
  227. return;
  228. }
  229. })
  230. .finally(() => {
  231. // Important to set scrollQueueRef.current to null and trigger a rerender
  232. // after the promise resolves as we show a loading state during scroll,
  233. // else the screen could jump around while we fetch span data
  234. scrollQueueRef.current = null;
  235. rerenderRef.current();
  236. });
  237. }, [
  238. api,
  239. trace,
  240. trace_id,
  241. manager,
  242. onTraceLoad,
  243. traceDispatch,
  244. scrollQueueRef,
  245. initializedRef,
  246. organization,
  247. ]);
  248. const onNodeZoomIn = useCallback(
  249. (
  250. event: React.MouseEvent<Element> | React.KeyboardEvent<Element>,
  251. node: TraceTreeNode<TraceTree.NodeValue>,
  252. value: boolean
  253. ) => {
  254. if (!isTransactionNode(node) && !isSpanNode(node)) {
  255. throw new TypeError('Node must be a transaction or span');
  256. }
  257. event.stopPropagation();
  258. rerenderRef.current();
  259. treeRef.current
  260. .zoomIn(node, value, {
  261. api,
  262. organization,
  263. })
  264. .then(() => {
  265. rerenderRef.current();
  266. // If a query exists, we want to reapply the search after zooming in
  267. // so that new nodes are also highlighted if they match a query
  268. if (traceStateRef.current.search.query) {
  269. onTraceSearch(traceStateRef.current.search.query, node, 'persist');
  270. }
  271. treePromiseStatusRef.current!.set(node, 'success');
  272. })
  273. .catch(_e => {
  274. treePromiseStatusRef.current!.set(node, 'error');
  275. });
  276. },
  277. [api, organization, onTraceSearch]
  278. );
  279. const onNodeExpand = useCallback(
  280. (
  281. event: React.MouseEvent<Element> | React.KeyboardEvent<Element>,
  282. node: TraceTreeNode<TraceTree.NodeValue>,
  283. value: boolean
  284. ) => {
  285. event.stopPropagation();
  286. treeRef.current.expand(node, value);
  287. rerenderRef.current();
  288. if (traceStateRef.current.search.query) {
  289. // If a query exists, we want to reapply the search after expanding
  290. // so that new nodes are also highlighted if they match a query
  291. onTraceSearch(traceStateRef.current.search.query, node, 'persist');
  292. }
  293. },
  294. [onTraceSearch]
  295. );
  296. const onRowKeyDown = useCallback(
  297. (
  298. event: React.KeyboardEvent,
  299. index: number,
  300. node: TraceTreeNode<TraceTree.NodeValue>
  301. ) => {
  302. if (!manager.list) {
  303. return;
  304. }
  305. const action = getRovingIndexActionFromDOMEvent(event);
  306. if (action) {
  307. event.preventDefault();
  308. const nextIndex = computeNextIndexFromAction(
  309. index,
  310. action,
  311. treeRef.current.list.length - 1
  312. );
  313. traceDispatch({
  314. type: 'set roving index',
  315. index: nextIndex,
  316. node: treeRef.current.list[nextIndex],
  317. action_source: 'keyboard',
  318. });
  319. }
  320. if (event.key === 'ArrowLeft') {
  321. if (node.zoomedIn) onNodeZoomIn(event, node, false);
  322. else if (node.expanded) onNodeExpand(event, node, false);
  323. } else if (event.key === 'ArrowRight') {
  324. if (!node.expanded) onNodeExpand(event, node, true);
  325. else if (node.expanded && node.canFetch) onNodeZoomIn(event, node, true);
  326. }
  327. },
  328. [manager, onNodeExpand, onNodeZoomIn, traceDispatch]
  329. );
  330. const projectLookup: Record<string, PlatformKey | undefined> = useMemo(() => {
  331. return projects.reduce<Record<Project['slug'], Project['platform']>>(
  332. (acc, project) => {
  333. acc[project.slug] = project.platform;
  334. return acc;
  335. },
  336. {}
  337. );
  338. }, [projects]);
  339. const renderLoadingRow = useCallback(
  340. (n: VirtualizedRow) => {
  341. return (
  342. <RenderPlaceholderRow
  343. key={n.key}
  344. index={n.index}
  345. style={n.style}
  346. node={n.item}
  347. theme={theme}
  348. manager={manager}
  349. />
  350. );
  351. },
  352. [manager, theme]
  353. );
  354. const renderVirtualizedRow = useCallback(
  355. (n: VirtualizedRow) => {
  356. return (
  357. <RenderRow
  358. key={n.key}
  359. index={n.index}
  360. organization={organization}
  361. previouslyFocusedNodeRef={previouslyFocusedNodeRef}
  362. tabIndex={traceState.rovingTabIndex.node === n.item ? 0 : -1}
  363. isSearchResult={traceState.search.resultsLookup.has(n.item)}
  364. searchResultsIteratorIndex={traceState.search.resultIndex}
  365. style={n.style}
  366. trace_id={trace_id}
  367. projects={projectLookup}
  368. node={n.item}
  369. manager={manager}
  370. theme={theme}
  371. onExpand={onNodeExpand}
  372. onZoomIn={onNodeZoomIn}
  373. onRowClick={onRowClick}
  374. onRowKeyDown={onRowKeyDown}
  375. />
  376. );
  377. },
  378. // we add forceRerender as a "unnecessary" dependency to trigger the virtualized list rerender
  379. // eslint-disable-next-line react-hooks/exhaustive-deps
  380. [
  381. onNodeExpand,
  382. onNodeZoomIn,
  383. manager,
  384. scrollQueueRef,
  385. previouslyFocusedNodeRef,
  386. onRowKeyDown,
  387. onRowClick,
  388. organization,
  389. projectLookup,
  390. traceState.rovingTabIndex.node,
  391. traceState.search.resultIteratorIndex,
  392. traceState.search.resultsLookup,
  393. traceState.search.resultIndex,
  394. theme,
  395. trace_id,
  396. trace.type,
  397. forceRerender,
  398. ]
  399. );
  400. const render = useMemo(() => {
  401. return trace.type !== 'trace' || scrollQueueRef.current
  402. ? r => renderLoadingRow(r)
  403. : r => renderVirtualizedRow(r);
  404. }, [renderLoadingRow, renderVirtualizedRow, trace.type, scrollQueueRef]);
  405. const [scrollContainer, setScrollContainer] = useState<HTMLElement | null>(null);
  406. const virtualizedList = useVirtualizedList({
  407. manager,
  408. items: trace.list,
  409. container: scrollContainer,
  410. render: render,
  411. });
  412. const traceNode = trace.root.children[0];
  413. const traceStartTimestamp = traceNode?.space?.[0];
  414. return (
  415. <TraceStylingWrapper
  416. ref={manager.registerContainerRef}
  417. className={`
  418. ${trace?.root?.space?.[1] === 0 ? 'Empty' : ''}
  419. ${trace.indicators.length > 0 ? 'WithIndicators' : ''}
  420. ${trace.type !== 'trace' || scrollQueueRef.current ? 'Loading' : ''}
  421. ${ConfigStore.get('theme')}`}
  422. >
  423. <div
  424. className="TraceScrollbarContainer"
  425. ref={manager.registerHorizontalScrollBarContainerRef}
  426. >
  427. <div className="TraceScrollbarScroller" />
  428. </div>
  429. <div className="TraceDivider" ref={manager.registerDividerRef} />
  430. <div
  431. className="TraceIndicatorContainer"
  432. ref={manager.registerIndicatorContainerRef}
  433. >
  434. {trace.indicators.length > 0
  435. ? trace.indicators.map((indicator, i) => {
  436. return (
  437. <div
  438. key={i}
  439. ref={r => manager.registerIndicatorRef(r, i, indicator)}
  440. className={`TraceIndicator ${indicator.poor ? 'Errored' : ''}`}
  441. >
  442. <div className="TraceIndicatorLabel">{indicator.label}</div>
  443. <div className="TraceIndicatorLine" />
  444. </div>
  445. );
  446. })
  447. : null}
  448. {manager.interval_bars.map((_, i) => {
  449. const indicatorTimestamp = manager.intervals[i] ?? 0;
  450. if (trace.type !== 'trace') {
  451. return null;
  452. }
  453. return (
  454. <div
  455. key={i}
  456. ref={r => manager.registerTimelineIndicatorRef(r, i)}
  457. className="TraceIndicator Timeline"
  458. >
  459. <div className="TraceIndicatorLabel">
  460. {indicatorTimestamp > 0
  461. ? formatTraceDuration(manager.trace_view.x + indicatorTimestamp)
  462. : '0s'}
  463. </div>
  464. <div className="TraceIndicatorLine" />
  465. </div>
  466. );
  467. })}
  468. {traceNode && traceStartTimestamp ? (
  469. <VerticalTimestampIndicators
  470. viewmanager={manager}
  471. traceStartTimestamp={traceStartTimestamp}
  472. />
  473. ) : null}
  474. </div>
  475. <div
  476. ref={setScrollContainer}
  477. data-test-id="trace-virtualized-list-scroll-container"
  478. >
  479. <div data-test-id="trace-virtualized-list">{virtualizedList.rendered}</div>
  480. <div className="TraceRow Hidden">
  481. <div
  482. className="TraceLeftColumn"
  483. ref={r => manager.registerGhostRowRef('list', r)}
  484. />
  485. <div
  486. className="TraceRightColumn"
  487. ref={r => manager.registerGhostRowRef('span_list', r)}
  488. />
  489. </div>
  490. </div>
  491. </TraceStylingWrapper>
  492. );
  493. }
  494. function RenderRow(props: {
  495. index: number;
  496. isSearchResult: boolean;
  497. manager: VirtualizedViewManager;
  498. node: TraceTreeNode<TraceTree.NodeValue>;
  499. onExpand: (
  500. event: React.MouseEvent<Element>,
  501. node: TraceTreeNode<TraceTree.NodeValue>,
  502. value: boolean
  503. ) => void;
  504. onRowClick: (
  505. node: TraceTreeNode<TraceTree.NodeValue>,
  506. event: React.MouseEvent<HTMLElement>,
  507. index: number
  508. ) => void;
  509. onRowKeyDown: (
  510. event: React.KeyboardEvent,
  511. index: number,
  512. node: TraceTreeNode<TraceTree.NodeValue>
  513. ) => void;
  514. onZoomIn: (
  515. event: React.MouseEvent<Element>,
  516. node: TraceTreeNode<TraceTree.NodeValue>,
  517. value: boolean
  518. ) => void;
  519. organization: Organization;
  520. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>;
  521. projects: Record<Project['slug'], Project['platform']>;
  522. searchResultsIteratorIndex: number | null;
  523. style: React.CSSProperties;
  524. tabIndex: number;
  525. theme: Theme;
  526. trace_id: string;
  527. }) {
  528. const virtualized_index = props.index - props.manager.start_virtualized_index;
  529. const rowSearchClassName = `${props.isSearchResult ? 'SearchResult' : ''} ${props.searchResultsIteratorIndex === props.index ? 'Highlight' : ''}`;
  530. const registerListColumnRef = useCallback(
  531. (ref: HTMLDivElement | null) => {
  532. props.manager.registerColumnRef('list', ref, virtualized_index, props.node);
  533. },
  534. [props.manager, props.node, virtualized_index]
  535. );
  536. const registerSpanColumnRef = useCallback(
  537. (ref: HTMLDivElement | null) => {
  538. props.manager.registerColumnRef('span_list', ref, virtualized_index, props.node);
  539. },
  540. [props.manager, props.node, virtualized_index]
  541. );
  542. const registerSpanArrowRef = useCallback(
  543. ref => {
  544. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index);
  545. },
  546. [props.manager, props.node, virtualized_index]
  547. );
  548. const onRowClickProp = props.onRowClick;
  549. const onRowClick = useCallback(
  550. (event: React.MouseEvent<HTMLElement>) => {
  551. onRowClickProp(props.node, event, props.index);
  552. },
  553. [props.index, props.node, onRowClickProp]
  554. );
  555. const onKeyDownProp = props.onRowKeyDown;
  556. const onRowKeyDown = useCallback(
  557. event => onKeyDownProp(event, props.index, props.node),
  558. [props.index, props.node, onKeyDownProp]
  559. );
  560. const onSpanRowDoubleClick = useCallback(
  561. e => {
  562. trackAnalytics('trace.trace_layout.zoom_to_fill', {
  563. organization: props.organization,
  564. });
  565. e.stopPropagation();
  566. props.manager.onZoomIntoSpace(props.node.space!);
  567. },
  568. [props.node, props.manager, props.organization]
  569. );
  570. const onSpanRowArrowClick = useCallback(
  571. _e => {
  572. props.manager.onBringRowIntoView(props.node.space!);
  573. },
  574. [props.node.space, props.manager]
  575. );
  576. const onExpandProp = props.onExpand;
  577. const onExpandClick = useCallback(
  578. e => onExpandProp(e, props.node, !props.node.expanded),
  579. [props.node, onExpandProp]
  580. );
  581. const spanColumnClassName =
  582. props.index % 2 === 1 ? RIGHT_COLUMN_ODD_CLASSNAME : RIGHT_COLUMN_EVEN_CLASSNAME;
  583. const listColumnClassName = props.node.isOrphaned
  584. ? CHILDREN_COUNT_WRAPPER_ORPHANED_CLASSNAME
  585. : CHILDREN_COUNT_WRAPPER_CLASSNAME;
  586. const listColumnStyle: React.CSSProperties = {
  587. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  588. };
  589. if (isAutogroupedNode(props.node)) {
  590. return (
  591. <div
  592. key={props.index}
  593. ref={r =>
  594. props.tabIndex === 0
  595. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  596. : null
  597. }
  598. tabIndex={props.tabIndex}
  599. className={`Autogrouped TraceRow ${rowSearchClassName} ${props.node.has_errors ? props.node.max_severity : ''}`}
  600. onClick={onRowClick}
  601. onKeyDown={onRowKeyDown}
  602. style={props.style}
  603. >
  604. <div className="TraceLeftColumn" ref={registerListColumnRef}>
  605. <div className={`TraceLeftColumnInner`} style={listColumnStyle}>
  606. <div className="TraceChildrenCountWrapper">
  607. <Connectors node={props.node} manager={props.manager} />
  608. <ChildrenButton
  609. icon={
  610. <TraceIcons.Chevron direction={props.node.expanded ? 'up' : 'down'} />
  611. }
  612. status={props.node.fetchStatus}
  613. expanded={!props.node.expanded}
  614. onClick={onExpandClick}
  615. >
  616. {COUNT_FORMATTER.format(props.node.groupCount)}
  617. </ChildrenButton>
  618. </div>
  619. <span className="TraceOperation">{t('Autogrouped')}</span>
  620. <strong className="TraceEmDash"> — </strong>
  621. <span className="TraceDescription">{props.node.value.autogrouped_by.op}</span>
  622. </div>
  623. </div>
  624. <div
  625. className={spanColumnClassName}
  626. ref={registerSpanColumnRef}
  627. onDoubleClick={onSpanRowDoubleClick}
  628. >
  629. <AutogroupedTraceBar
  630. manager={props.manager}
  631. entire_space={props.node.space}
  632. errors={props.node.errors}
  633. virtualized_index={virtualized_index}
  634. color={makeTraceNodeBarColor(props.theme, props.node)}
  635. node_spaces={props.node.autogroupedSegments}
  636. performance_issues={props.node.performance_issues}
  637. profiles={props.node.profiles}
  638. />
  639. <button
  640. ref={registerSpanArrowRef}
  641. className="TraceArrow"
  642. onClick={onSpanRowArrowClick}
  643. >
  644. <TraceIcons.Chevron direction="left" />
  645. </button>
  646. </div>
  647. </div>
  648. );
  649. }
  650. if (isTransactionNode(props.node)) {
  651. return (
  652. <div
  653. key={props.index}
  654. ref={r =>
  655. props.tabIndex === 0
  656. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  657. : null
  658. }
  659. tabIndex={props.tabIndex}
  660. className={`TraceRow ${rowSearchClassName} ${props.node.has_errors ? props.node.max_severity : ''}`}
  661. onKeyDown={onRowKeyDown}
  662. onClick={onRowClick}
  663. style={props.style}
  664. >
  665. <div className="TraceLeftColumn" ref={registerListColumnRef}>
  666. <div className={`TraceLeftColumnInner`} style={listColumnStyle}>
  667. <div className={listColumnClassName}>
  668. <Connectors node={props.node} manager={props.manager} />
  669. {props.node.children.length > 0 || props.node.canFetch ? (
  670. <ChildrenButton
  671. icon={
  672. props.node.canFetch && props.node.fetchStatus === 'idle' ? (
  673. '+'
  674. ) : props.node.canFetch && props.node.zoomedIn ? (
  675. <TraceIcons.Chevron direction="down" />
  676. ) : (
  677. '+'
  678. )
  679. }
  680. status={props.node.fetchStatus}
  681. expanded={props.node.expanded || props.node.zoomedIn}
  682. onClick={e => {
  683. props.node.canFetch
  684. ? props.onZoomIn(e, props.node, !props.node.zoomedIn)
  685. : props.onExpand(e, props.node, !props.node.expanded);
  686. }}
  687. >
  688. {props.node.children.length > 0
  689. ? COUNT_FORMATTER.format(props.node.children.length)
  690. : null}
  691. </ChildrenButton>
  692. ) : null}
  693. </div>
  694. <PlatformIcon
  695. platform={props.projects[props.node.value.project_slug] ?? 'default'}
  696. />
  697. <span className="TraceOperation">{props.node.value['transaction.op']}</span>
  698. <strong className="TraceEmDash"> — </strong>
  699. <span>{props.node.value.transaction}</span>
  700. </div>
  701. </div>
  702. <div
  703. ref={registerSpanColumnRef}
  704. className={spanColumnClassName}
  705. onDoubleClick={onSpanRowDoubleClick}
  706. >
  707. <TraceBar
  708. virtualized_index={virtualized_index}
  709. manager={props.manager}
  710. color={makeTraceNodeBarColor(props.theme, props.node)}
  711. node_space={props.node.space}
  712. errors={props.node.errors}
  713. performance_issues={props.node.performance_issues}
  714. profiles={props.node.profiles}
  715. />
  716. <button
  717. ref={registerSpanArrowRef}
  718. className="TraceArrow"
  719. onClick={onSpanRowArrowClick}
  720. >
  721. <TraceIcons.Chevron direction="left" />
  722. </button>
  723. </div>
  724. </div>
  725. );
  726. }
  727. if (isSpanNode(props.node)) {
  728. return (
  729. <div
  730. key={props.index}
  731. ref={r =>
  732. props.tabIndex === 0
  733. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  734. : null
  735. }
  736. tabIndex={props.tabIndex}
  737. className={`TraceRow ${rowSearchClassName} ${props.node.has_errors ? props.node.max_severity : ''}`}
  738. onClick={onRowClick}
  739. onKeyDown={onRowKeyDown}
  740. style={props.style}
  741. >
  742. <div className="TraceLeftColumn" ref={registerListColumnRef}>
  743. <div className={`TraceLeftColumnInner`} style={listColumnStyle}>
  744. <div className={listColumnClassName}>
  745. <Connectors node={props.node} manager={props.manager} />
  746. {props.node.children.length > 0 || props.node.canFetch ? (
  747. <ChildrenButton
  748. icon={
  749. props.node.canFetch ? (
  750. '+'
  751. ) : (
  752. <TraceIcons.Chevron
  753. direction={props.node.expanded ? 'up' : 'down'}
  754. />
  755. )
  756. }
  757. status={props.node.fetchStatus}
  758. expanded={props.node.expanded || props.node.zoomedIn}
  759. onClick={e =>
  760. props.node.canFetch
  761. ? props.onZoomIn(e, props.node, !props.node.zoomedIn)
  762. : props.onExpand(e, props.node, !props.node.expanded)
  763. }
  764. >
  765. {props.node.children.length > 0
  766. ? COUNT_FORMATTER.format(props.node.children.length)
  767. : null}
  768. </ChildrenButton>
  769. ) : null}
  770. </div>
  771. <span className="TraceOperation">{props.node.value.op ?? '<unknown>'}</span>
  772. <strong className="TraceEmDash"> — </strong>
  773. <span className="TraceDescription" title={props.node.value.description}>
  774. {!props.node.value.description
  775. ? props.node.value.span_id ?? 'unknown'
  776. : props.node.value.description.length > 100
  777. ? props.node.value.description.slice(0, 100).trim() + '\u2026'
  778. : props.node.value.description}
  779. </span>
  780. </div>
  781. </div>
  782. <div
  783. ref={registerSpanColumnRef}
  784. className={spanColumnClassName}
  785. onDoubleClick={onSpanRowDoubleClick}
  786. >
  787. <TraceBar
  788. virtualized_index={virtualized_index}
  789. manager={props.manager}
  790. color={makeTraceNodeBarColor(props.theme, props.node)}
  791. node_space={props.node.space}
  792. errors={props.node.errors}
  793. performance_issues={props.node.performance_issues}
  794. profiles={NO_PROFILES}
  795. />
  796. <button
  797. ref={registerSpanArrowRef}
  798. className="TraceArrow"
  799. onClick={onSpanRowArrowClick}
  800. >
  801. <TraceIcons.Chevron direction="left" />
  802. </button>
  803. </div>
  804. </div>
  805. );
  806. }
  807. if (isMissingInstrumentationNode(props.node)) {
  808. return (
  809. <div
  810. key={props.index}
  811. ref={r =>
  812. props.tabIndex === 0
  813. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  814. : null
  815. }
  816. tabIndex={props.tabIndex}
  817. className={`TraceRow ${rowSearchClassName}`}
  818. onClick={onRowClick}
  819. onKeyDown={onRowKeyDown}
  820. style={props.style}
  821. >
  822. <div className="TraceLeftColumn" ref={registerListColumnRef}>
  823. <div className="TraceLeftColumnInner" style={listColumnStyle}>
  824. <div className="TraceChildrenCountWrapper">
  825. <Connectors node={props.node} manager={props.manager} />
  826. </div>
  827. <span className="TraceOperation">{t('Missing instrumentation')}</span>
  828. </div>
  829. </div>
  830. <div
  831. ref={registerSpanColumnRef}
  832. className={spanColumnClassName}
  833. onDoubleClick={onSpanRowDoubleClick}
  834. >
  835. <MissingInstrumentationTraceBar
  836. virtualized_index={virtualized_index}
  837. manager={props.manager}
  838. color={makeTraceNodeBarColor(props.theme, props.node)}
  839. node_space={props.node.space}
  840. />
  841. <button
  842. ref={registerSpanArrowRef}
  843. className="TraceArrow"
  844. onClick={onSpanRowArrowClick}
  845. >
  846. <TraceIcons.Chevron direction="left" />
  847. </button>
  848. </div>
  849. </div>
  850. );
  851. }
  852. if (isTraceNode(props.node)) {
  853. return (
  854. <div
  855. key={props.index}
  856. ref={r =>
  857. props.tabIndex === 0
  858. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  859. : null
  860. }
  861. tabIndex={props.tabIndex}
  862. className={`TraceRow ${rowSearchClassName} ${props.node.has_errors ? props.node.max_severity : ''}`}
  863. onClick={onRowClick}
  864. onKeyDown={onRowKeyDown}
  865. style={props.style}
  866. >
  867. <div className="TraceLeftColumn" ref={registerListColumnRef}>
  868. <div className="TraceLeftColumnInner" style={listColumnStyle}>
  869. {' '}
  870. <div className="TraceChildrenCountWrapper Root">
  871. <Connectors node={props.node} manager={props.manager} />
  872. {props.node.children.length > 0 || props.node.canFetch ? (
  873. <ChildrenButton icon={''} status={'idle'} expanded onClick={() => void 0}>
  874. {props.node.children.length > 0
  875. ? COUNT_FORMATTER.format(props.node.children.length)
  876. : null}
  877. </ChildrenButton>
  878. ) : null}
  879. </div>
  880. <span className="TraceOperation">{t('Trace')}</span>
  881. <strong className="TraceEmDash"> — </strong>
  882. <span className="TraceDescription">{props.trace_id}</span>
  883. </div>
  884. </div>
  885. <div
  886. ref={registerSpanColumnRef}
  887. className={spanColumnClassName}
  888. onDoubleClick={onSpanRowDoubleClick}
  889. >
  890. <TraceBar
  891. virtualized_index={virtualized_index}
  892. manager={props.manager}
  893. color={makeTraceNodeBarColor(props.theme, props.node)}
  894. node_space={props.node.space}
  895. errors={NO_ERRORS}
  896. performance_issues={NO_PERFORMANCE_ISSUES}
  897. profiles={NO_PROFILES}
  898. />
  899. <button
  900. ref={registerSpanArrowRef}
  901. className="TraceArrow"
  902. onClick={onSpanRowArrowClick}
  903. >
  904. <TraceIcons.Chevron direction="left" />
  905. </button>
  906. </div>
  907. </div>
  908. );
  909. }
  910. if (isTraceErrorNode(props.node)) {
  911. return (
  912. <div
  913. key={props.index}
  914. ref={r =>
  915. props.tabIndex === 0
  916. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  917. : null
  918. }
  919. tabIndex={props.tabIndex}
  920. className={`TraceRow ${rowSearchClassName} ${props.node.max_severity}`}
  921. onClick={onRowClick}
  922. onKeyDown={onRowKeyDown}
  923. style={props.style}
  924. >
  925. <div className="TraceLeftColumn" ref={registerListColumnRef}>
  926. <div className="TraceLeftColumnInner" style={listColumnStyle}>
  927. <div className="TraceChildrenCountWrapper">
  928. <Connectors node={props.node} manager={props.manager} />{' '}
  929. </div>
  930. <PlatformIcon
  931. platform={props.projects[props.node.value.project_slug] ?? 'default'}
  932. />
  933. <span className="TraceOperation">
  934. {ERROR_LEVEL_LABELS[props.node.value.level ?? 'error']}
  935. </span>
  936. <strong className="TraceEmDash"> — </strong>
  937. <span className="TraceDescription">
  938. {props.node.value.message ?? props.node.value.title}
  939. </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. transform: props.style.transform,
  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.errors.size > 0 ? (
  1185. <ErrorIcons
  1186. node_space={props.node_space}
  1187. errors={props.errors}
  1188. manager={props.manager}
  1189. />
  1190. ) : null}
  1191. {props.performance_issues.size > 0 ? (
  1192. <PerformanceIssueIcons
  1193. node_space={props.node_space}
  1194. performance_issues={props.performance_issues}
  1195. manager={props.manager}
  1196. />
  1197. ) : null}
  1198. {props.performance_issues.size > 0 ||
  1199. props.errors.size > 0 ||
  1200. props.profiles.length > 0 ? (
  1201. <BackgroundPatterns
  1202. node_space={props.node_space}
  1203. performance_issues={props.performance_issues}
  1204. errors={props.errors}
  1205. manager={props.manager}
  1206. />
  1207. ) : null}
  1208. </div>
  1209. <div ref={registerSpanBarTextRef} className="TraceBarDuration">
  1210. {duration}
  1211. </div>
  1212. </Fragment>
  1213. );
  1214. }
  1215. interface MissingInstrumentationTraceBarProps {
  1216. color: string;
  1217. manager: VirtualizedViewManager;
  1218. node_space: [number, number] | null;
  1219. virtualized_index: number;
  1220. }
  1221. function MissingInstrumentationTraceBar(props: MissingInstrumentationTraceBarProps) {
  1222. const duration = props.node_space ? formatTraceDuration(props.node_space[1]) : null;
  1223. const registerSpanBarRef = useCallback(
  1224. (ref: HTMLDivElement | null) => {
  1225. props.manager.registerSpanBarRef(
  1226. ref,
  1227. props.node_space!,
  1228. props.color,
  1229. props.virtualized_index
  1230. );
  1231. },
  1232. [props.manager, props.node_space, props.color, props.virtualized_index]
  1233. );
  1234. const registerSpanBarTextRef = useCallback(
  1235. (ref: HTMLDivElement | null) => {
  1236. props.manager.registerSpanBarTextRef(
  1237. ref,
  1238. duration!,
  1239. props.node_space!,
  1240. props.virtualized_index
  1241. );
  1242. },
  1243. [props.manager, props.node_space, props.virtualized_index, duration]
  1244. );
  1245. return (
  1246. <Fragment>
  1247. <div ref={registerSpanBarRef} className="TraceBar">
  1248. <div className="TracePatternContainer">
  1249. <div className="TracePattern missing_instrumentation" />
  1250. </div>
  1251. </div>
  1252. <div ref={registerSpanBarTextRef} className="TraceBarDuration">
  1253. {duration}
  1254. </div>
  1255. </Fragment>
  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. function VerticalTimestampIndicators({
  1538. viewmanager,
  1539. traceStartTimestamp,
  1540. }: {
  1541. traceStartTimestamp: number;
  1542. viewmanager: VirtualizedViewManager;
  1543. }) {
  1544. useEffect(() => {
  1545. function replayTimestampListener({
  1546. currentTime,
  1547. currentHoverTime,
  1548. }: {
  1549. currentHoverTime: number | undefined;
  1550. currentTime: number;
  1551. }) {
  1552. if (viewmanager.vertical_indicators['replay_timestamp.current']) {
  1553. viewmanager.vertical_indicators['replay_timestamp.current'].timestamp =
  1554. traceStartTimestamp + currentTime;
  1555. }
  1556. if (viewmanager.vertical_indicators['replay_timestamp.hover']) {
  1557. viewmanager.vertical_indicators['replay_timestamp.hover'].timestamp =
  1558. currentHoverTime ? traceStartTimestamp + currentHoverTime : undefined;
  1559. }
  1560. // When timestamp is changing, it needs to be redrawn
  1561. // if it is out of bounds, we need to scroll to it
  1562. viewmanager.drawVerticalIndicators();
  1563. viewmanager.maybeSyncViewWithVerticalIndicator('replay_timestamp.current');
  1564. }
  1565. replayPlayerTimestampEmitter.on('replay timestamp change', replayTimestampListener);
  1566. return () => {
  1567. replayPlayerTimestampEmitter.off(
  1568. 'replay timestamp change',
  1569. replayTimestampListener
  1570. );
  1571. };
  1572. }, [traceStartTimestamp, viewmanager]);
  1573. const registerReplayCurrentTimestampRef = useCallback(
  1574. (ref: HTMLDivElement | null) => {
  1575. viewmanager.registerVerticalIndicator('replay_timestamp.current', {
  1576. ref,
  1577. timestamp: undefined,
  1578. });
  1579. },
  1580. [viewmanager]
  1581. );
  1582. const registerReplayHoverTimestampRef = useCallback(
  1583. (ref: HTMLDivElement | null) => {
  1584. viewmanager.registerVerticalIndicator('replay_timestamp.hover', {
  1585. ref,
  1586. timestamp: undefined,
  1587. });
  1588. },
  1589. [viewmanager]
  1590. );
  1591. return (
  1592. <Fragment>
  1593. <div ref={registerReplayCurrentTimestampRef} className="TraceIndicator Timeline">
  1594. <div className="Indicator CurrentReplayTimestamp" />
  1595. </div>
  1596. <div ref={registerReplayHoverTimestampRef} className="TraceIndicator Timeline">
  1597. <div className="Indicator HoverReplayTimestamp" />
  1598. </div>
  1599. </Fragment>
  1600. );
  1601. }
  1602. /**
  1603. * This is a wrapper around the Trace component to apply styles
  1604. * to the trace tree. It exists because we _do not_ want to trigger
  1605. * emotion's css parsing logic as it is very slow and will cause
  1606. * the scrolling to flicker.
  1607. */
  1608. const TraceStylingWrapper = styled('div')`
  1609. margin: auto;
  1610. overscroll-behavior: none;
  1611. box-shadow: 0 0 0 1px ${p => p.theme.border};
  1612. position: absolute;
  1613. left: 0;
  1614. top: 0;
  1615. width: 100%;
  1616. height: 100%;
  1617. grid-area: trace;
  1618. padding-top: 26px;
  1619. &.WithIndicators {
  1620. padding-top: 44px;
  1621. &:before {
  1622. height: 44px;
  1623. .TraceScrollbarContainer {
  1624. height: 44px;
  1625. }
  1626. }
  1627. .TraceIndicator.Timeline {
  1628. .TraceIndicatorLabel {
  1629. top: 26px;
  1630. }
  1631. .TraceIndicatorLine {
  1632. top: 30px;
  1633. }
  1634. .Indicator {
  1635. top: 44px;
  1636. }
  1637. }
  1638. }
  1639. &:before {
  1640. content: '';
  1641. position: absolute;
  1642. left: 0;
  1643. top: 0;
  1644. width: 100%;
  1645. height: 26px;
  1646. background-color: ${p => p.theme.backgroundSecondary};
  1647. border-bottom: 1px solid ${p => p.theme.border};
  1648. }
  1649. &.Loading {
  1650. .TraceRow {
  1651. .TraceLeftColumnInner {
  1652. width: 100%;
  1653. }
  1654. }
  1655. .TraceRightColumn {
  1656. background-color: transparent !important;
  1657. }
  1658. .TraceDivider {
  1659. pointer-events: none;
  1660. }
  1661. }
  1662. &.Empty {
  1663. .TraceIcon {
  1664. left: 50%;
  1665. }
  1666. }
  1667. .TraceScrollbarContainer {
  1668. left: 0;
  1669. top: 0;
  1670. height: 26px;
  1671. position: absolute;
  1672. overflow-x: auto;
  1673. overscroll-behavior: none;
  1674. will-change: transform;
  1675. .TraceScrollbarScroller {
  1676. height: 1px;
  1677. pointer-events: none;
  1678. visibility: hidden;
  1679. }
  1680. .TraceScrollbarHandle {
  1681. width: 24px;
  1682. height: 12px;
  1683. border-radius: 6px;
  1684. }
  1685. }
  1686. .TraceDivider {
  1687. position: absolute;
  1688. height: 100%;
  1689. background-color: transparent;
  1690. top: 0;
  1691. cursor: ew-resize;
  1692. z-index: 10;
  1693. &:before {
  1694. content: '';
  1695. position: absolute;
  1696. width: 1px;
  1697. height: 100%;
  1698. background-color: ${p => p.theme.border};
  1699. left: 50%;
  1700. }
  1701. &:hover {
  1702. &:before {
  1703. background-color: ${p => p.theme.purple300};
  1704. }
  1705. }
  1706. }
  1707. .TraceIndicatorContainer {
  1708. overflow: hidden;
  1709. width: 100%;
  1710. height: 100%;
  1711. position: absolute;
  1712. right: 0;
  1713. top: 0;
  1714. z-index: 10;
  1715. pointer-events: none;
  1716. }
  1717. .TraceIndicator {
  1718. z-index: 1;
  1719. width: 3px;
  1720. height: 100%;
  1721. top: 0;
  1722. position: absolute;
  1723. &:hover {
  1724. z-index: 10;
  1725. }
  1726. .TraceIndicatorLabel {
  1727. min-width: 34px;
  1728. text-align: center;
  1729. position: absolute;
  1730. font-size: 10px;
  1731. font-weight: ${p => p.theme.fontWeightBold};
  1732. color: ${p => p.theme.textColor};
  1733. background-color: ${p => p.theme.background};
  1734. border-radius: ${p => p.theme.borderRadius};
  1735. border: 1px solid ${p => p.theme.border};
  1736. padding: 2px;
  1737. display: inline-block;
  1738. line-height: 1;
  1739. margin-top: 2px;
  1740. white-space: nowrap;
  1741. }
  1742. .TraceIndicatorLine {
  1743. width: 1px;
  1744. height: 100%;
  1745. top: 20px;
  1746. position: absolute;
  1747. left: 50%;
  1748. transform: translateX(-2px);
  1749. background: repeating-linear-gradient(
  1750. to bottom,
  1751. transparent 0 4px,
  1752. ${p => p.theme.textColor} 4px 8px
  1753. )
  1754. 80%/2px 100% no-repeat;
  1755. }
  1756. .Indicator {
  1757. width: 1px;
  1758. height: 100%;
  1759. position: absolute;
  1760. left: 50%;
  1761. transform: translateX(-2px);
  1762. top: 26px;
  1763. &.CurrentReplayTimestamp {
  1764. background: ${p => p.theme.purple300};
  1765. }
  1766. &.HoverReplayTimestamp {
  1767. background: ${p => p.theme.purple200};
  1768. }
  1769. }
  1770. &.Errored {
  1771. .TraceIndicatorLabel {
  1772. border: 1px solid ${p => p.theme.error};
  1773. color: ${p => p.theme.error};
  1774. }
  1775. .TraceIndicatorLine {
  1776. background: repeating-linear-gradient(
  1777. to bottom,
  1778. transparent 0 4px,
  1779. ${p => p.theme.error} 4px 8px
  1780. )
  1781. 80%/2px 100% no-repeat;
  1782. }
  1783. }
  1784. &.Timeline {
  1785. opacity: 1;
  1786. z-index: 1;
  1787. pointer-events: none;
  1788. .TraceIndicatorLabel {
  1789. font-weight: ${p => p.theme.fontWeightNormal};
  1790. min-width: 0;
  1791. top: 8px;
  1792. width: auto;
  1793. border: none;
  1794. background-color: transparent;
  1795. color: ${p => p.theme.subText};
  1796. }
  1797. .TraceIndicatorLine {
  1798. background: ${p => p.theme.translucentGray100};
  1799. top: 8px;
  1800. }
  1801. }
  1802. }
  1803. &.light {
  1804. .TracePattern {
  1805. &.info {
  1806. --pattern-odd: #d1dff9;
  1807. --pattern-even: ${p => p.theme.blue300};
  1808. }
  1809. &.warning {
  1810. --pattern-odd: #a5752c;
  1811. --pattern-even: ${p => p.theme.yellow300};
  1812. }
  1813. &.performance_issue {
  1814. --pattern-odd: #063690;
  1815. --pattern-even: ${p => p.theme.blue300};
  1816. }
  1817. &.profile {
  1818. --pattern-odd: rgba(58, 17, 95, 0.55);
  1819. --pattern-even: transparent;
  1820. }
  1821. &.missing_instrumentation {
  1822. --pattern-odd: #4b4550;
  1823. --pattern-even: rgb(128, 112, 143);
  1824. }
  1825. &.error,
  1826. &.fatal {
  1827. --pattern-odd: #872d32;
  1828. --pattern-even: ${p => p.theme.red300};
  1829. }
  1830. /* false positive for grid layout */
  1831. /* stylelint-disable */
  1832. &.default {
  1833. }
  1834. &.unknown {
  1835. }
  1836. /* stylelint-enable */
  1837. }
  1838. }
  1839. &.dark {
  1840. .TracePattern {
  1841. &.info {
  1842. --pattern-odd: #d1dff9;
  1843. --pattern-even: ${p => p.theme.blue300};
  1844. }
  1845. &.warning {
  1846. --pattern-odd: #a5752c;
  1847. --pattern-even: ${p => p.theme.yellow300};
  1848. }
  1849. &.performance_issue {
  1850. --pattern-odd: #063690;
  1851. --pattern-even: ${p => p.theme.blue300};
  1852. }
  1853. &.profile {
  1854. --pattern-odd: rgba(58, 17, 95, 0.55);
  1855. --pattern-even: transparent;
  1856. }
  1857. &.missing_instrumentation {
  1858. --pattern-odd: #4b4550;
  1859. --pattern-even: #1c1521;
  1860. }
  1861. &.error,
  1862. &.fatal {
  1863. --pattern-odd: #510d10;
  1864. --pattern-even: ${p => p.theme.red300};
  1865. }
  1866. /* stylelint-disable */
  1867. &.default {
  1868. }
  1869. &.unknown {
  1870. }
  1871. /* stylelint-enable */
  1872. }
  1873. }
  1874. .TraceRow {
  1875. display: flex;
  1876. align-items: center;
  1877. position: absolute;
  1878. height: 24px;
  1879. width: 100%;
  1880. transition: none;
  1881. font-size: ${p => p.theme.fontSizeSmall};
  1882. transform: translateZ(0);
  1883. --row-background-odd: ${p => p.theme.translucentSurface100};
  1884. --row-background-hover: ${p => p.theme.translucentSurface100};
  1885. --row-background-focused: ${p => p.theme.translucentSurface200};
  1886. --row-outline: ${p => p.theme.blue300};
  1887. --row-children-button-border-color: ${p => p.theme.border};
  1888. /* allow empty blocks so we can keep an exhaustive list of classnames for future reference */
  1889. /* stylelint-disable */
  1890. &.info {
  1891. }
  1892. &.warning {
  1893. }
  1894. &.error,
  1895. &.fatal,
  1896. &.performance_issue {
  1897. color: ${p => p.theme.errorText};
  1898. --autogrouped: ${p => p.theme.error};
  1899. --row-children-button-border-color: ${p => p.theme.error};
  1900. --row-outline: ${p => p.theme.error};
  1901. }
  1902. &.default {
  1903. }
  1904. &.unknown {
  1905. }
  1906. &.Hidden {
  1907. position: absolute;
  1908. height: 100%;
  1909. width: 100%;
  1910. top: 0;
  1911. z-index: -1;
  1912. &:hover {
  1913. background-color: transparent;
  1914. }
  1915. * {
  1916. cursor: default !important;
  1917. }
  1918. }
  1919. .TraceIcon {
  1920. position: absolute;
  1921. top: 50%;
  1922. transform: translate(-50%, -50%) scaleX(var(--inverse-span-scale)) translateZ(0);
  1923. background-color: ${p => p.theme.background};
  1924. width: 18px !important;
  1925. height: 18px !important;
  1926. border-radius: 50%;
  1927. display: flex;
  1928. align-items: center;
  1929. justify-content: center;
  1930. z-index: 1;
  1931. &.info {
  1932. background-color: var(--info);
  1933. }
  1934. &.warning {
  1935. background-color: var(--warning);
  1936. }
  1937. &.error,
  1938. &.fatal {
  1939. background-color: var(--error);
  1940. }
  1941. &.performance_issue {
  1942. background-color: var(--performance-issue);
  1943. }
  1944. &.default {
  1945. background-color: var(--default);
  1946. }
  1947. &.unknown {
  1948. background-color: var(--unknown);
  1949. }
  1950. &.profile {
  1951. background-color: var(--profile);
  1952. }
  1953. svg {
  1954. width: 12px;
  1955. height: 12px;
  1956. fill: ${p => p.theme.white};
  1957. }
  1958. &.profile svg {
  1959. margin-left: 2px;
  1960. }
  1961. &.info,
  1962. &.warning,
  1963. &.performance_issue,
  1964. &.default,
  1965. &.unknown {
  1966. svg {
  1967. transform: translateY(-1px);
  1968. }
  1969. }
  1970. }
  1971. .TracePatternContainer {
  1972. position: absolute;
  1973. width: 100%;
  1974. height: 100%;
  1975. overflow: hidden;
  1976. }
  1977. .TracePattern {
  1978. left: 0;
  1979. width: 1000000px;
  1980. height: 100%;
  1981. position: absolute;
  1982. transform-origin: left center;
  1983. transform: scaleX(var(--inverse-span-scale)) translateZ(0);
  1984. background-image: linear-gradient(
  1985. 135deg,
  1986. var(--pattern-even) 1%,
  1987. var(--pattern-even) 11%,
  1988. var(--pattern-odd) 11%,
  1989. var(--pattern-odd) 21%,
  1990. var(--pattern-even) 21%,
  1991. var(--pattern-even) 31%,
  1992. var(--pattern-odd) 31%,
  1993. var(--pattern-odd) 41%,
  1994. var(--pattern-even) 41%,
  1995. var(--pattern-even) 51%,
  1996. var(--pattern-odd) 51%,
  1997. var(--pattern-odd) 61%,
  1998. var(--pattern-even) 61%,
  1999. var(--pattern-even) 71%,
  2000. var(--pattern-odd) 71%,
  2001. var(--pattern-odd) 81%,
  2002. var(--pattern-even) 81%,
  2003. var(--pattern-even) 91%,
  2004. var(--pattern-odd) 91%,
  2005. var(--pattern-odd) 101%
  2006. );
  2007. background-size: 25.5px 17px;
  2008. }
  2009. .TracePerformanceIssue {
  2010. position: absolute;
  2011. top: 0;
  2012. display: flex;
  2013. align-items: center;
  2014. justify-content: flex-start;
  2015. background-color: var(--performance-issue);
  2016. height: 16px;
  2017. }
  2018. .TraceRightColumn.Odd {
  2019. background-color: var(--row-background-odd);
  2020. }
  2021. &:hover {
  2022. background-color: var(--row-background-hovered);
  2023. }
  2024. &.Highlight {
  2025. box-shadow: inset 0 0 0 1px ${p => p.theme.blue200} !important;
  2026. .TraceLeftColumn {
  2027. box-shadow: inset 0px 0 0px 1px ${p => p.theme.blue200} !important;
  2028. }
  2029. }
  2030. &.Highlight,
  2031. &:focus,
  2032. &[tabindex='0'] {
  2033. outline: none;
  2034. background-color: var(--row-background-focused);
  2035. .TraceRightColumn.Odd {
  2036. background-color: transparent !important;
  2037. }
  2038. }
  2039. &:focus,
  2040. &[tabindex='0'] {
  2041. background-color: var(--row-background-focused);
  2042. box-shadow: inset 0 0 0 1px var(--row-outline) !important;
  2043. .TraceLeftColumn {
  2044. box-shadow: inset 0px 0 0px 1px var(--row-outline) !important;
  2045. }
  2046. .TraceRightColumn.Odd {
  2047. background-color: transparent !important;
  2048. }
  2049. }
  2050. &.SearchResult {
  2051. background-color: ${p => p.theme.yellow100};
  2052. .TraceRightColumn {
  2053. background-color: transparent;
  2054. }
  2055. }
  2056. &.Autogrouped {
  2057. color: ${p => p.theme.blue300};
  2058. .TraceDescription {
  2059. font-weight: ${p => p.theme.fontWeightBold};
  2060. }
  2061. .TraceChildrenCountWrapper {
  2062. button {
  2063. color: ${p => p.theme.white};
  2064. background-color: ${p => p.theme.blue300};
  2065. }
  2066. svg {
  2067. fill: ${p => p.theme.white};
  2068. }
  2069. }
  2070. }
  2071. }
  2072. .TraceLeftColumn {
  2073. height: 100%;
  2074. white-space: nowrap;
  2075. display: flex;
  2076. align-items: center;
  2077. overflow: hidden;
  2078. will-change: width;
  2079. box-shadow: inset 1px 0 0px 0px transparent;
  2080. cursor: pointer;
  2081. width: calc(var(--list-column-width) * 100%);
  2082. .TraceLeftColumnInner {
  2083. height: 100%;
  2084. white-space: nowrap;
  2085. display: flex;
  2086. align-items: center;
  2087. will-change: transform;
  2088. transform-origin: left center;
  2089. padding-right: ${space(2)};
  2090. img {
  2091. width: 16px;
  2092. height: 16px;
  2093. }
  2094. }
  2095. }
  2096. .TraceRightColumn {
  2097. height: 100%;
  2098. overflow: hidden;
  2099. position: relative;
  2100. display: flex;
  2101. align-items: center;
  2102. will-change: width;
  2103. z-index: 1;
  2104. cursor: pointer;
  2105. width: calc(var(--span-column-width) * 100%);
  2106. &:hover {
  2107. .TraceArrow.Visible {
  2108. opacity: 1;
  2109. transition: 300ms 300ms ease-out;
  2110. pointer-events: auto;
  2111. }
  2112. }
  2113. }
  2114. .TraceBar {
  2115. position: absolute;
  2116. height: 16px;
  2117. width: 100%;
  2118. background-color: black;
  2119. transform-origin: left center;
  2120. &.Invisible {
  2121. background-color: transparent !important;
  2122. > div {
  2123. height: 100%;
  2124. }
  2125. }
  2126. svg {
  2127. width: 14px;
  2128. height: 14px;
  2129. }
  2130. }
  2131. .TraceArrow {
  2132. position: absolute;
  2133. pointer-events: none;
  2134. top: 0;
  2135. width: 14px;
  2136. height: 24px;
  2137. opacity: 0;
  2138. background-color: transparent;
  2139. border: none;
  2140. transition: 60ms ease-out;
  2141. font-size: ${p => p.theme.fontSizeMedium};
  2142. color: ${p => p.theme.subText};
  2143. padding: 0 2px;
  2144. display: flex;
  2145. align-items: center;
  2146. svg {
  2147. fill: ${p => p.theme.subText};
  2148. }
  2149. &.Left {
  2150. left: 0;
  2151. }
  2152. &.Right {
  2153. right: 0;
  2154. transform: rotate(180deg);
  2155. }
  2156. }
  2157. .TraceBarDuration {
  2158. display: inline-block;
  2159. transform-origin: left center;
  2160. font-size: ${p => p.theme.fontSizeExtraSmall};
  2161. color: ${p => p.theme.gray300};
  2162. white-space: nowrap;
  2163. font-variant-numeric: tabular-nums;
  2164. position: absolute;
  2165. }
  2166. .TraceChildrenCount {
  2167. height: 16px;
  2168. white-space: nowrap;
  2169. min-width: 30px;
  2170. display: flex;
  2171. align-items: center;
  2172. justify-content: center;
  2173. border-radius: 99px;
  2174. padding: 0px 4px;
  2175. transition: all 0.15s ease-in-out;
  2176. background: ${p => p.theme.background};
  2177. border: 1.5px solid var(--row-children-button-border-color);
  2178. line-height: 0;
  2179. z-index: 1;
  2180. font-size: 10px;
  2181. box-shadow: ${p => p.theme.dropShadowLight};
  2182. margin-right: 8px;
  2183. .TraceChildrenCountContent {
  2184. + .TraceChildrenCountAction {
  2185. margin-left: 2px;
  2186. }
  2187. }
  2188. .TraceChildrenCountAction {
  2189. position: relative;
  2190. display: flex;
  2191. align-items: center;
  2192. justify-content: center;
  2193. }
  2194. .TraceActionsLoadingIndicator {
  2195. margin: 0;
  2196. position: absolute;
  2197. top: 50%;
  2198. left: 50%;
  2199. transform: translate(-50%, -50%);
  2200. background-color: ${p => p.theme.background};
  2201. animation: show 0.1s ease-in-out forwards;
  2202. @keyframes show {
  2203. from {
  2204. opacity: 0;
  2205. transform: translate(-50%, -50%) scale(0.86);
  2206. }
  2207. to {
  2208. opacity: 1;
  2209. transform: translate(-50%, -50%) scale(1);
  2210. }
  2211. }
  2212. .loading-indicator {
  2213. border-width: 2px;
  2214. }
  2215. .loading-message {
  2216. display: none;
  2217. }
  2218. }
  2219. svg {
  2220. width: 7px;
  2221. transition: none;
  2222. }
  2223. }
  2224. .TraceChildrenCountWrapper {
  2225. display: flex;
  2226. justify-content: flex-end;
  2227. align-items: center;
  2228. min-width: 44px;
  2229. height: 100%;
  2230. position: relative;
  2231. button {
  2232. transition: none;
  2233. }
  2234. svg {
  2235. fill: currentColor;
  2236. }
  2237. &.Orphaned {
  2238. .TraceVerticalConnector,
  2239. .TraceVerticalLastChildConnector,
  2240. .TraceExpandedVerticalConnector {
  2241. border-left: 2px dashed ${p => p.theme.border};
  2242. }
  2243. &::before {
  2244. border-bottom: 2px dashed ${p => p.theme.border};
  2245. }
  2246. }
  2247. &.Root {
  2248. &:before,
  2249. .TraceVerticalLastChildConnector {
  2250. visibility: hidden;
  2251. }
  2252. }
  2253. &::before {
  2254. content: '';
  2255. display: block;
  2256. width: 50%;
  2257. height: 2px;
  2258. border-bottom: 2px solid ${p => p.theme.border};
  2259. position: absolute;
  2260. left: 0;
  2261. top: 50%;
  2262. transform: translateY(-50%);
  2263. }
  2264. &::after {
  2265. content: '';
  2266. background-color: ${p => p.theme.border};
  2267. border-radius: 50%;
  2268. height: 6px;
  2269. width: 6px;
  2270. position: absolute;
  2271. left: 50%;
  2272. top: 50%;
  2273. transform: translateY(-50%);
  2274. }
  2275. }
  2276. .TraceVerticalConnector {
  2277. position: absolute;
  2278. left: 0;
  2279. top: 0;
  2280. bottom: 0;
  2281. height: 100%;
  2282. width: 2px;
  2283. border-left: 2px solid ${p => p.theme.border};
  2284. &.Orphaned {
  2285. border-left: 2px dashed ${p => p.theme.border};
  2286. }
  2287. }
  2288. .TraceVerticalLastChildConnector {
  2289. position: absolute;
  2290. left: 0;
  2291. top: 0;
  2292. bottom: 0;
  2293. height: 50%;
  2294. width: 2px;
  2295. border-left: 2px solid ${p => p.theme.border};
  2296. border-bottom-left-radius: 4px;
  2297. }
  2298. .TraceExpandedVerticalConnector {
  2299. position: absolute;
  2300. bottom: 0;
  2301. height: 50%;
  2302. left: 50%;
  2303. width: 2px;
  2304. border-left: 2px solid ${p => p.theme.border};
  2305. }
  2306. .TraceOperation {
  2307. margin-left: 4px;
  2308. text-overflow: ellipsis;
  2309. white-space: nowrap;
  2310. font-weight: ${p => p.theme.fontWeightBold};
  2311. }
  2312. .TraceEmDash {
  2313. margin-left: 4px;
  2314. margin-right: 4px;
  2315. }
  2316. .TraceDescription {
  2317. white-space: nowrap;
  2318. }
  2319. `;