trace.tsx 68 KB

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