trace.tsx 72 KB

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