trace.tsx 66 KB

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