trace.tsx 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548
  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. <div
  1347. key={i}
  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. );
  1357. })}
  1358. </Fragment>
  1359. ) : null}
  1360. </Fragment>
  1361. );
  1362. }
  1363. interface ErrorIconsProps {
  1364. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1365. manager: VirtualizedViewManager;
  1366. node_space: [number, number] | null;
  1367. }
  1368. function ErrorIcons(props: ErrorIconsProps) {
  1369. const errors = useMemo(() => {
  1370. return [...props.errors];
  1371. }, [props.errors]);
  1372. if (!props.errors.size) {
  1373. return null;
  1374. }
  1375. return (
  1376. <Fragment>
  1377. {errors.map((error, i) => {
  1378. const timestamp = error.timestamp ? error.timestamp * 1e3 : props.node_space![0];
  1379. // Clamp the error timestamp to the span's timestamp
  1380. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1381. clamp(
  1382. timestamp,
  1383. props.node_space![0],
  1384. props.node_space![0] + props.node_space![1]
  1385. ),
  1386. props.node_space!
  1387. );
  1388. return (
  1389. <div
  1390. key={i}
  1391. className={`TraceIcon ${error.level}`}
  1392. style={{left: left * 100 + '%'}}
  1393. >
  1394. <TraceIcons.Icon event={error} />
  1395. </div>
  1396. );
  1397. })}
  1398. </Fragment>
  1399. );
  1400. }
  1401. interface PerformanceIssueIconsProps {
  1402. manager: VirtualizedViewManager;
  1403. node_space: [number, number] | null;
  1404. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1405. }
  1406. function PerformanceIssueIcons(props: PerformanceIssueIconsProps) {
  1407. const performance_issues = useMemo(() => {
  1408. return [...props.performance_issues];
  1409. }, [props.performance_issues]);
  1410. if (!props.performance_issues.size) {
  1411. return null;
  1412. }
  1413. return (
  1414. <Fragment>
  1415. {performance_issues.map((issue, i) => {
  1416. const timestamp = issue.timestamp
  1417. ? issue.timestamp * 1e3
  1418. : issue.start
  1419. ? issue.start * 1e3
  1420. : props.node_space![0];
  1421. // Clamp the issue timestamp to the span's timestamp
  1422. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1423. clamp(
  1424. timestamp,
  1425. props.node_space![0],
  1426. props.node_space![0] + props.node_space![1]
  1427. ),
  1428. props.node_space!
  1429. );
  1430. return (
  1431. <div
  1432. key={i}
  1433. className={`TraceIcon performance_issue`}
  1434. style={{left: left * 100 + '%'}}
  1435. >
  1436. <TraceIcons.Icon event={issue} />
  1437. </div>
  1438. );
  1439. })}
  1440. </Fragment>
  1441. );
  1442. }
  1443. interface AutogroupedTraceBarProps {
  1444. color: string;
  1445. entire_space: [number, number] | null;
  1446. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1447. manager: VirtualizedViewManager;
  1448. node_spaces: [number, number][];
  1449. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1450. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1451. virtualized_index: number;
  1452. }
  1453. function AutogroupedTraceBar(props: AutogroupedTraceBarProps) {
  1454. const duration = props.entire_space ? formatTraceDuration(props.entire_space[1]) : null;
  1455. const registerInvisibleBarRef = useCallback(
  1456. (ref: HTMLDivElement | null) => {
  1457. props.manager.registerInvisibleBarRef(
  1458. ref,
  1459. props.entire_space!,
  1460. props.virtualized_index
  1461. );
  1462. },
  1463. [props.manager, props.entire_space, props.virtualized_index]
  1464. );
  1465. const registerAutogroupedSpanBarTextRef = useCallback(
  1466. (ref: HTMLDivElement | null) => {
  1467. props.manager.registerSpanBarTextRef(
  1468. ref,
  1469. duration!,
  1470. props.entire_space!,
  1471. props.virtualized_index
  1472. );
  1473. },
  1474. [props.manager, props.entire_space, props.virtualized_index, duration]
  1475. );
  1476. if (props.node_spaces && props.node_spaces.length <= 1) {
  1477. return (
  1478. <TraceBar
  1479. color={props.color}
  1480. node_space={props.entire_space}
  1481. manager={props.manager}
  1482. virtualized_index={props.virtualized_index}
  1483. errors={props.errors}
  1484. performance_issues={props.performance_issues}
  1485. profiles={props.profiles}
  1486. />
  1487. );
  1488. }
  1489. if (!props.node_spaces || !props.entire_space) {
  1490. return null;
  1491. }
  1492. return (
  1493. <Fragment>
  1494. <div ref={registerInvisibleBarRef} className="TraceBar Invisible">
  1495. {props.node_spaces.map((node_space, i) => {
  1496. const width = node_space[1] / props.entire_space![1];
  1497. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1498. node_space[0],
  1499. props.entire_space!
  1500. );
  1501. return (
  1502. <div
  1503. key={i}
  1504. className="TraceBar"
  1505. style={{
  1506. left: `${left * 100}%`,
  1507. width: `${width * 100}%`,
  1508. backgroundColor: props.color,
  1509. }}
  1510. />
  1511. );
  1512. })}
  1513. {/* Autogrouped bars only render icons. That is because in the case of multiple bars
  1514. with tiny gaps, the background pattern looks broken as it does not repeat nicely */}
  1515. {props.errors.size > 0 ? (
  1516. <ErrorIcons
  1517. node_space={props.entire_space}
  1518. errors={props.errors}
  1519. manager={props.manager}
  1520. />
  1521. ) : null}
  1522. {props.performance_issues.size > 0 ? (
  1523. <PerformanceIssueIcons
  1524. node_space={props.entire_space}
  1525. performance_issues={props.performance_issues}
  1526. manager={props.manager}
  1527. />
  1528. ) : null}
  1529. </div>
  1530. <div ref={registerAutogroupedSpanBarTextRef} className="TraceBarDuration">
  1531. {duration}
  1532. </div>
  1533. </Fragment>
  1534. );
  1535. }
  1536. function VerticalTimestampIndicators({
  1537. viewmanager,
  1538. traceStartTimestamp,
  1539. }: {
  1540. traceStartTimestamp: number;
  1541. viewmanager: VirtualizedViewManager;
  1542. }) {
  1543. useEffect(() => {
  1544. function replayTimestampListener({
  1545. currentTime,
  1546. currentHoverTime,
  1547. }: {
  1548. currentHoverTime: number | undefined;
  1549. currentTime: number;
  1550. }) {
  1551. if (viewmanager.vertical_indicators['replay_timestamp.current']) {
  1552. viewmanager.vertical_indicators['replay_timestamp.current'].timestamp =
  1553. traceStartTimestamp + currentTime;
  1554. }
  1555. if (viewmanager.vertical_indicators['replay_timestamp.hover']) {
  1556. viewmanager.vertical_indicators['replay_timestamp.hover'].timestamp =
  1557. currentHoverTime ? traceStartTimestamp + currentHoverTime : undefined;
  1558. }
  1559. // When timestamp is changing, it needs to be redrawn
  1560. // if it is out of bounds, we need to scroll to it
  1561. viewmanager.drawVerticalIndicators();
  1562. viewmanager.maybeSyncViewWithVerticalIndicator('replay_timestamp.current');
  1563. }
  1564. replayPlayerTimestampEmitter.on('replay timestamp change', replayTimestampListener);
  1565. return () => {
  1566. replayPlayerTimestampEmitter.off(
  1567. 'replay timestamp change',
  1568. replayTimestampListener
  1569. );
  1570. };
  1571. }, [traceStartTimestamp, viewmanager]);
  1572. const registerReplayCurrentTimestampRef = useCallback(
  1573. (ref: HTMLDivElement | null) => {
  1574. viewmanager.registerVerticalIndicator('replay_timestamp.current', {
  1575. ref,
  1576. timestamp: undefined,
  1577. });
  1578. },
  1579. [viewmanager]
  1580. );
  1581. const registerReplayHoverTimestampRef = useCallback(
  1582. (ref: HTMLDivElement | null) => {
  1583. viewmanager.registerVerticalIndicator('replay_timestamp.hover', {
  1584. ref,
  1585. timestamp: undefined,
  1586. });
  1587. },
  1588. [viewmanager]
  1589. );
  1590. return (
  1591. <Fragment>
  1592. <div ref={registerReplayCurrentTimestampRef} className="TraceIndicator Timeline">
  1593. <div className="Indicator CurrentReplayTimestamp" />
  1594. </div>
  1595. <div ref={registerReplayHoverTimestampRef} className="TraceIndicator Timeline">
  1596. <div className="Indicator HoverReplayTimestamp" />
  1597. </div>
  1598. </Fragment>
  1599. );
  1600. }
  1601. /**
  1602. * This is a wrapper around the Trace component to apply styles
  1603. * to the trace tree. It exists because we _do not_ want to trigger
  1604. * emotion's css parsing logic as it is very slow and will cause
  1605. * the scrolling to flicker.
  1606. */
  1607. const TraceStylingWrapper = styled('div')`
  1608. margin: auto;
  1609. overscroll-behavior: none;
  1610. box-shadow: 0 0 0 1px ${p => p.theme.border};
  1611. position: absolute;
  1612. left: 0;
  1613. top: 0;
  1614. width: 100%;
  1615. height: 100%;
  1616. grid-area: trace;
  1617. padding-top: 26px;
  1618. &.WithIndicators {
  1619. padding-top: 44px;
  1620. &:before {
  1621. height: 44px;
  1622. .TraceScrollbarContainer {
  1623. height: 44px;
  1624. }
  1625. }
  1626. .TraceIndicator.Timeline {
  1627. .TraceIndicatorLabel {
  1628. top: 26px;
  1629. }
  1630. .TraceIndicatorLine {
  1631. top: 30px;
  1632. }
  1633. .Indicator {
  1634. top: 44px;
  1635. }
  1636. }
  1637. }
  1638. &:before {
  1639. content: '';
  1640. position: absolute;
  1641. left: 0;
  1642. top: 0;
  1643. width: 100%;
  1644. height: 26px;
  1645. background-color: ${p => p.theme.backgroundSecondary};
  1646. border-bottom: 1px solid ${p => p.theme.border};
  1647. }
  1648. &.Loading {
  1649. .TraceRow {
  1650. .TraceLeftColumnInner {
  1651. width: 100%;
  1652. }
  1653. }
  1654. .TraceRightColumn {
  1655. background-color: transparent !important;
  1656. }
  1657. .TraceDivider {
  1658. pointer-events: none;
  1659. }
  1660. }
  1661. &.Empty {
  1662. .TraceIcon {
  1663. left: 50%;
  1664. }
  1665. }
  1666. .TraceScrollbarContainer {
  1667. left: 0;
  1668. top: 0;
  1669. height: 26px;
  1670. position: absolute;
  1671. overflow-x: auto;
  1672. overscroll-behavior: none;
  1673. will-change: transform;
  1674. .TraceScrollbarScroller {
  1675. height: 1px;
  1676. pointer-events: none;
  1677. visibility: hidden;
  1678. }
  1679. .TraceScrollbarHandle {
  1680. width: 24px;
  1681. height: 12px;
  1682. border-radius: 6px;
  1683. }
  1684. }
  1685. .TraceDivider {
  1686. position: absolute;
  1687. height: 100%;
  1688. background-color: transparent;
  1689. top: 0;
  1690. cursor: ew-resize;
  1691. z-index: 10;
  1692. &:before {
  1693. content: '';
  1694. position: absolute;
  1695. width: 1px;
  1696. height: 100%;
  1697. background-color: ${p => p.theme.border};
  1698. left: 50%;
  1699. }
  1700. &:hover {
  1701. &:before {
  1702. background-color: ${p => p.theme.purple300};
  1703. }
  1704. }
  1705. }
  1706. .TraceIndicatorContainer {
  1707. overflow: hidden;
  1708. width: 100%;
  1709. height: 100%;
  1710. position: absolute;
  1711. right: 0;
  1712. top: 0;
  1713. z-index: 10;
  1714. pointer-events: none;
  1715. }
  1716. .TraceIndicator {
  1717. z-index: 1;
  1718. width: 3px;
  1719. height: 100%;
  1720. top: 0;
  1721. position: absolute;
  1722. &:hover {
  1723. z-index: 10;
  1724. }
  1725. .TraceIndicatorLabel {
  1726. min-width: 34px;
  1727. text-align: center;
  1728. position: absolute;
  1729. font-size: 10px;
  1730. font-weight: ${p => p.theme.fontWeightBold};
  1731. color: ${p => p.theme.textColor};
  1732. background-color: ${p => p.theme.background};
  1733. border-radius: ${p => p.theme.borderRadius};
  1734. border: 1px solid ${p => p.theme.border};
  1735. padding: 2px;
  1736. display: inline-block;
  1737. line-height: 1;
  1738. margin-top: 2px;
  1739. white-space: nowrap;
  1740. }
  1741. .TraceIndicatorLine {
  1742. width: 1px;
  1743. height: 100%;
  1744. top: 20px;
  1745. position: absolute;
  1746. left: 50%;
  1747. transform: translateX(-2px);
  1748. background: repeating-linear-gradient(
  1749. to bottom,
  1750. transparent 0 4px,
  1751. ${p => p.theme.textColor} 4px 8px
  1752. )
  1753. 80%/2px 100% no-repeat;
  1754. }
  1755. .Indicator {
  1756. width: 1px;
  1757. height: 100%;
  1758. position: absolute;
  1759. left: 50%;
  1760. transform: translateX(-2px);
  1761. top: 26px;
  1762. &.CurrentReplayTimestamp {
  1763. background: ${p => p.theme.purple300};
  1764. }
  1765. &.HoverReplayTimestamp {
  1766. background: ${p => p.theme.purple200};
  1767. }
  1768. }
  1769. &.Errored {
  1770. .TraceIndicatorLabel {
  1771. border: 1px solid ${p => p.theme.error};
  1772. color: ${p => p.theme.error};
  1773. }
  1774. .TraceIndicatorLine {
  1775. background: repeating-linear-gradient(
  1776. to bottom,
  1777. transparent 0 4px,
  1778. ${p => p.theme.error} 4px 8px
  1779. )
  1780. 80%/2px 100% no-repeat;
  1781. }
  1782. }
  1783. &.Timeline {
  1784. opacity: 1;
  1785. z-index: 1;
  1786. pointer-events: none;
  1787. .TraceIndicatorLabel {
  1788. font-weight: ${p => p.theme.fontWeightNormal};
  1789. min-width: 0;
  1790. top: 8px;
  1791. width: auto;
  1792. border: none;
  1793. background-color: transparent;
  1794. color: ${p => p.theme.subText};
  1795. }
  1796. .TraceIndicatorLine {
  1797. background: ${p => p.theme.translucentGray100};
  1798. top: 8px;
  1799. }
  1800. }
  1801. }
  1802. &.light {
  1803. .TracePattern {
  1804. &.info {
  1805. --pattern-odd: #d1dff9;
  1806. --pattern-even: ${p => p.theme.blue300};
  1807. }
  1808. &.warning {
  1809. --pattern-odd: #a5752c;
  1810. --pattern-even: ${p => p.theme.yellow300};
  1811. }
  1812. &.performance_issue {
  1813. --pattern-odd: #063690;
  1814. --pattern-even: ${p => p.theme.blue300};
  1815. }
  1816. &.profile {
  1817. --pattern-odd: rgba(58, 17, 95, 0.55);
  1818. --pattern-even: transparent;
  1819. }
  1820. &.missing_instrumentation {
  1821. --pattern-odd: #4b4550;
  1822. --pattern-even: rgb(128, 112, 143);
  1823. }
  1824. &.error,
  1825. &.fatal {
  1826. --pattern-odd: #872d32;
  1827. --pattern-even: ${p => p.theme.red300};
  1828. }
  1829. /* false positive for grid layout */
  1830. /* stylelint-disable */
  1831. &.default {
  1832. }
  1833. &.unknown {
  1834. }
  1835. /* stylelint-enable */
  1836. }
  1837. }
  1838. &.dark {
  1839. .TracePattern {
  1840. &.info {
  1841. --pattern-odd: #d1dff9;
  1842. --pattern-even: ${p => p.theme.blue300};
  1843. }
  1844. &.warning {
  1845. --pattern-odd: #a5752c;
  1846. --pattern-even: ${p => p.theme.yellow300};
  1847. }
  1848. &.performance_issue {
  1849. --pattern-odd: #063690;
  1850. --pattern-even: ${p => p.theme.blue300};
  1851. }
  1852. &.profile {
  1853. --pattern-odd: rgba(58, 17, 95, 0.55);
  1854. --pattern-even: transparent;
  1855. }
  1856. &.missing_instrumentation {
  1857. --pattern-odd: #4b4550;
  1858. --pattern-even: #1c1521;
  1859. }
  1860. &.error,
  1861. &.fatal {
  1862. --pattern-odd: #510d10;
  1863. --pattern-even: ${p => p.theme.red300};
  1864. }
  1865. /* stylelint-disable */
  1866. &.default {
  1867. }
  1868. &.unknown {
  1869. }
  1870. /* stylelint-enable */
  1871. }
  1872. }
  1873. .TraceRow {
  1874. display: flex;
  1875. align-items: center;
  1876. position: absolute;
  1877. height: 24px;
  1878. width: 100%;
  1879. transition: none;
  1880. font-size: ${p => p.theme.fontSizeSmall};
  1881. transform: translateZ(0);
  1882. --row-background-odd: ${p => p.theme.translucentSurface100};
  1883. --row-background-hover: ${p => p.theme.translucentSurface100};
  1884. --row-background-focused: ${p => p.theme.translucentSurface200};
  1885. --row-outline: ${p => p.theme.blue300};
  1886. --row-children-button-border-color: ${p => p.theme.border};
  1887. /* allow empty blocks so we can keep an exhaustive list of classnames for future reference */
  1888. /* stylelint-disable */
  1889. &.info {
  1890. }
  1891. &.warning {
  1892. }
  1893. &.error,
  1894. &.fatal,
  1895. &.performance_issue {
  1896. color: ${p => p.theme.errorText};
  1897. --autogrouped: ${p => p.theme.error};
  1898. --row-children-button-border-color: ${p => p.theme.error};
  1899. --row-outline: ${p => p.theme.error};
  1900. }
  1901. &.default {
  1902. }
  1903. &.unknown {
  1904. }
  1905. &.Hidden {
  1906. position: absolute;
  1907. height: 100%;
  1908. width: 100%;
  1909. top: 0;
  1910. z-index: -1;
  1911. &:hover {
  1912. background-color: transparent;
  1913. }
  1914. * {
  1915. cursor: default !important;
  1916. }
  1917. }
  1918. .TraceIcon {
  1919. position: absolute;
  1920. top: 50%;
  1921. transform: translate(-50%, -50%) scaleX(var(--inverse-span-scale)) translateZ(0);
  1922. background-color: ${p => p.theme.background};
  1923. width: 18px !important;
  1924. height: 18px !important;
  1925. border-radius: 50%;
  1926. display: flex;
  1927. align-items: center;
  1928. justify-content: center;
  1929. z-index: 1;
  1930. &.info {
  1931. background-color: var(--info);
  1932. }
  1933. &.warning {
  1934. background-color: var(--warning);
  1935. }
  1936. &.error,
  1937. &.fatal {
  1938. background-color: var(--error);
  1939. }
  1940. &.performance_issue {
  1941. background-color: var(--performance-issue);
  1942. }
  1943. &.default {
  1944. background-color: var(--default);
  1945. }
  1946. &.unknown {
  1947. background-color: var(--unknown);
  1948. }
  1949. &.profile {
  1950. background-color: var(--profile);
  1951. }
  1952. svg {
  1953. width: 12px;
  1954. height: 12px;
  1955. fill: ${p => p.theme.white};
  1956. }
  1957. &.profile svg {
  1958. margin-left: 2px;
  1959. }
  1960. &.info,
  1961. &.warning,
  1962. &.performance_issue,
  1963. &.default,
  1964. &.unknown {
  1965. svg {
  1966. transform: translateY(-1px);
  1967. }
  1968. }
  1969. }
  1970. .TracePatternContainer {
  1971. position: absolute;
  1972. width: 100%;
  1973. height: 100%;
  1974. overflow: hidden;
  1975. }
  1976. .TracePattern {
  1977. left: 0;
  1978. width: 1000000px;
  1979. height: 100%;
  1980. position: absolute;
  1981. transform-origin: left center;
  1982. transform: scaleX(var(--inverse-span-scale)) translateZ(0);
  1983. background-image: linear-gradient(
  1984. 135deg,
  1985. var(--pattern-even) 1%,
  1986. var(--pattern-even) 11%,
  1987. var(--pattern-odd) 11%,
  1988. var(--pattern-odd) 21%,
  1989. var(--pattern-even) 21%,
  1990. var(--pattern-even) 31%,
  1991. var(--pattern-odd) 31%,
  1992. var(--pattern-odd) 41%,
  1993. var(--pattern-even) 41%,
  1994. var(--pattern-even) 51%,
  1995. var(--pattern-odd) 51%,
  1996. var(--pattern-odd) 61%,
  1997. var(--pattern-even) 61%,
  1998. var(--pattern-even) 71%,
  1999. var(--pattern-odd) 71%,
  2000. var(--pattern-odd) 81%,
  2001. var(--pattern-even) 81%,
  2002. var(--pattern-even) 91%,
  2003. var(--pattern-odd) 91%,
  2004. var(--pattern-odd) 101%
  2005. );
  2006. background-size: 25.5px 17px;
  2007. }
  2008. .TracePerformanceIssue {
  2009. position: absolute;
  2010. top: 0;
  2011. display: flex;
  2012. align-items: center;
  2013. justify-content: flex-start;
  2014. background-color: var(--performance-issue);
  2015. height: 16px;
  2016. }
  2017. .TraceRightColumn.Odd {
  2018. background-color: var(--row-background-odd);
  2019. }
  2020. &:hover {
  2021. background-color: var(--row-background-hovered);
  2022. }
  2023. &.Highlight {
  2024. box-shadow: inset 0 0 0 1px ${p => p.theme.blue200} !important;
  2025. .TraceLeftColumn {
  2026. box-shadow: inset 0px 0 0px 1px ${p => p.theme.blue200} !important;
  2027. }
  2028. }
  2029. &.Highlight,
  2030. &:focus,
  2031. &[tabindex='0'] {
  2032. outline: none;
  2033. background-color: var(--row-background-focused);
  2034. .TraceRightColumn.Odd {
  2035. background-color: transparent !important;
  2036. }
  2037. }
  2038. &:focus,
  2039. &[tabindex='0'] {
  2040. background-color: var(--row-background-focused);
  2041. box-shadow: inset 0 0 0 1px var(--row-outline) !important;
  2042. .TraceLeftColumn {
  2043. box-shadow: inset 0px 0 0px 1px var(--row-outline) !important;
  2044. }
  2045. .TraceRightColumn.Odd {
  2046. background-color: transparent !important;
  2047. }
  2048. }
  2049. &.SearchResult {
  2050. background-color: ${p => p.theme.yellow100};
  2051. .TraceRightColumn {
  2052. background-color: transparent;
  2053. }
  2054. }
  2055. &.Autogrouped {
  2056. color: ${p => p.theme.blue300};
  2057. .TraceDescription {
  2058. font-weight: ${p => p.theme.fontWeightBold};
  2059. }
  2060. .TraceChildrenCountWrapper {
  2061. button {
  2062. color: ${p => p.theme.white};
  2063. background-color: ${p => p.theme.blue300};
  2064. }
  2065. svg {
  2066. fill: ${p => p.theme.white};
  2067. }
  2068. }
  2069. &.error {
  2070. color: ${p => p.theme.red300};
  2071. .TraceChildrenCountWrapper {
  2072. button {
  2073. color: ${p => p.theme.white};
  2074. background-color: ${p => p.theme.red300};
  2075. }
  2076. }
  2077. }
  2078. }
  2079. }
  2080. .TraceLeftColumn {
  2081. height: 100%;
  2082. white-space: nowrap;
  2083. display: flex;
  2084. align-items: center;
  2085. overflow: hidden;
  2086. will-change: width;
  2087. box-shadow: inset 1px 0 0px 0px transparent;
  2088. cursor: pointer;
  2089. width: calc(var(--list-column-width) * 100%);
  2090. .TraceLeftColumnInner {
  2091. height: 100%;
  2092. white-space: nowrap;
  2093. display: flex;
  2094. align-items: center;
  2095. will-change: transform;
  2096. transform-origin: left center;
  2097. padding-right: ${space(2)};
  2098. img {
  2099. width: 16px;
  2100. height: 16px;
  2101. }
  2102. }
  2103. }
  2104. .TraceRightColumn {
  2105. height: 100%;
  2106. overflow: hidden;
  2107. position: relative;
  2108. display: flex;
  2109. align-items: center;
  2110. will-change: width;
  2111. z-index: 1;
  2112. cursor: pointer;
  2113. width: calc(var(--span-column-width) * 100%);
  2114. &:hover {
  2115. .TraceArrow.Visible {
  2116. opacity: 1;
  2117. transition: 300ms 300ms ease-out;
  2118. pointer-events: auto;
  2119. }
  2120. }
  2121. }
  2122. .TraceBar {
  2123. position: absolute;
  2124. height: 16px;
  2125. width: 100%;
  2126. background-color: black;
  2127. transform-origin: left center;
  2128. &.Invisible {
  2129. background-color: transparent !important;
  2130. > div {
  2131. height: 100%;
  2132. }
  2133. }
  2134. svg {
  2135. width: 14px;
  2136. height: 14px;
  2137. }
  2138. }
  2139. .TraceArrow {
  2140. position: absolute;
  2141. pointer-events: none;
  2142. top: 0;
  2143. width: 14px;
  2144. height: 24px;
  2145. opacity: 0;
  2146. background-color: transparent;
  2147. border: none;
  2148. transition: 60ms ease-out;
  2149. font-size: ${p => p.theme.fontSizeMedium};
  2150. color: ${p => p.theme.subText};
  2151. padding: 0 2px;
  2152. display: flex;
  2153. align-items: center;
  2154. svg {
  2155. fill: ${p => p.theme.subText};
  2156. }
  2157. &.Left {
  2158. left: 0;
  2159. }
  2160. &.Right {
  2161. right: 0;
  2162. transform: rotate(180deg);
  2163. }
  2164. }
  2165. .TraceBarDuration {
  2166. display: inline-block;
  2167. transform-origin: left center;
  2168. font-size: ${p => p.theme.fontSizeExtraSmall};
  2169. color: ${p => p.theme.gray300};
  2170. white-space: nowrap;
  2171. font-variant-numeric: tabular-nums;
  2172. position: absolute;
  2173. }
  2174. .TraceChildrenCount {
  2175. height: 16px;
  2176. white-space: nowrap;
  2177. min-width: 30px;
  2178. display: flex;
  2179. align-items: center;
  2180. justify-content: center;
  2181. border-radius: 99px;
  2182. padding: 0px 4px;
  2183. transition: all 0.15s ease-in-out;
  2184. background: ${p => p.theme.background};
  2185. border: 1.5px solid var(--row-children-button-border-color);
  2186. line-height: 0;
  2187. z-index: 1;
  2188. font-size: 10px;
  2189. box-shadow: ${p => p.theme.dropShadowLight};
  2190. margin-right: 8px;
  2191. .TraceChildrenCountContent {
  2192. + .TraceChildrenCountAction {
  2193. margin-left: 2px;
  2194. }
  2195. }
  2196. .TraceChildrenCountAction {
  2197. position: relative;
  2198. display: flex;
  2199. align-items: center;
  2200. justify-content: center;
  2201. }
  2202. .TraceActionsLoadingIndicator {
  2203. margin: 0;
  2204. position: absolute;
  2205. top: 50%;
  2206. left: 50%;
  2207. transform: translate(-50%, -50%);
  2208. background-color: ${p => p.theme.background};
  2209. animation: show 0.1s ease-in-out forwards;
  2210. @keyframes show {
  2211. from {
  2212. opacity: 0;
  2213. transform: translate(-50%, -50%) scale(0.86);
  2214. }
  2215. to {
  2216. opacity: 1;
  2217. transform: translate(-50%, -50%) scale(1);
  2218. }
  2219. }
  2220. .loading-indicator {
  2221. border-width: 2px;
  2222. }
  2223. .loading-message {
  2224. display: none;
  2225. }
  2226. }
  2227. svg {
  2228. width: 7px;
  2229. transition: none;
  2230. }
  2231. }
  2232. .TraceChildrenCountWrapper {
  2233. display: flex;
  2234. justify-content: flex-end;
  2235. align-items: center;
  2236. min-width: 44px;
  2237. height: 100%;
  2238. position: relative;
  2239. button {
  2240. transition: none;
  2241. }
  2242. svg {
  2243. fill: currentColor;
  2244. }
  2245. &.Orphaned {
  2246. .TraceVerticalConnector,
  2247. .TraceVerticalLastChildConnector,
  2248. .TraceExpandedVerticalConnector {
  2249. border-left: 2px dashed ${p => p.theme.border};
  2250. }
  2251. &::before {
  2252. border-bottom: 2px dashed ${p => p.theme.border};
  2253. }
  2254. }
  2255. &.Root {
  2256. &:before,
  2257. .TraceVerticalLastChildConnector {
  2258. visibility: hidden;
  2259. }
  2260. }
  2261. &::before {
  2262. content: '';
  2263. display: block;
  2264. width: 50%;
  2265. height: 2px;
  2266. border-bottom: 2px solid ${p => p.theme.border};
  2267. position: absolute;
  2268. left: 0;
  2269. top: 50%;
  2270. transform: translateY(-50%);
  2271. }
  2272. &::after {
  2273. content: '';
  2274. background-color: ${p => p.theme.border};
  2275. border-radius: 50%;
  2276. height: 6px;
  2277. width: 6px;
  2278. position: absolute;
  2279. left: 50%;
  2280. top: 50%;
  2281. transform: translateY(-50%);
  2282. }
  2283. }
  2284. .TraceVerticalConnector {
  2285. position: absolute;
  2286. left: 0;
  2287. top: 0;
  2288. bottom: 0;
  2289. height: 100%;
  2290. width: 2px;
  2291. border-left: 2px solid ${p => p.theme.border};
  2292. &.Orphaned {
  2293. border-left: 2px dashed ${p => p.theme.border};
  2294. }
  2295. }
  2296. .TraceVerticalLastChildConnector {
  2297. position: absolute;
  2298. left: 0;
  2299. top: 0;
  2300. bottom: 0;
  2301. height: 50%;
  2302. width: 2px;
  2303. border-left: 2px solid ${p => p.theme.border};
  2304. border-bottom-left-radius: 4px;
  2305. }
  2306. .TraceExpandedVerticalConnector {
  2307. position: absolute;
  2308. bottom: 0;
  2309. height: 50%;
  2310. left: 50%;
  2311. width: 2px;
  2312. border-left: 2px solid ${p => p.theme.border};
  2313. }
  2314. .TraceOperation {
  2315. margin-left: 4px;
  2316. text-overflow: ellipsis;
  2317. white-space: nowrap;
  2318. font-weight: ${p => p.theme.fontWeightBold};
  2319. }
  2320. .TraceEmDash {
  2321. margin-left: 4px;
  2322. margin-right: 4px;
  2323. }
  2324. .TraceDescription {
  2325. white-space: nowrap;
  2326. }
  2327. `;