trace.tsx 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359
  1. import type React from 'react';
  2. import {Fragment, useCallback, useEffect, useMemo, useRef, useState} from 'react';
  3. import {browserHistory} from 'react-router';
  4. import {type Theme, useTheme} from '@emotion/react';
  5. import styled from '@emotion/styled';
  6. import * as Sentry from '@sentry/react';
  7. import {PlatformIcon} from 'platformicons';
  8. import * as qs from 'query-string';
  9. import LoadingIndicator from 'sentry/components/loadingIndicator';
  10. import Placeholder from 'sentry/components/placeholder';
  11. import {t} from 'sentry/locale';
  12. import type {Organization, PlatformKey, Project} from 'sentry/types';
  13. import {getDuration} from 'sentry/utils/formatters';
  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 {
  23. getRovingIndexActionFromEvent,
  24. type RovingTabIndexAction,
  25. type RovingTabIndexUserActions,
  26. } from 'sentry/views/performance/newTraceDetails/rovingTabIndex';
  27. import type {
  28. TraceSearchAction,
  29. TraceSearchState,
  30. } from 'sentry/views/performance/newTraceDetails/traceSearch';
  31. import {
  32. isAutogroupedNode,
  33. isMissingInstrumentationNode,
  34. isParentAutogroupedNode,
  35. isSpanNode,
  36. isTraceErrorNode,
  37. isTraceNode,
  38. isTransactionNode,
  39. } from './guards';
  40. import {
  41. makeTraceNodeBarColor,
  42. ParentAutogroupNode,
  43. type TraceTree,
  44. type TraceTreeNode,
  45. } from './traceTree';
  46. import {
  47. useVirtualizedList,
  48. type VirtualizedRow,
  49. type VirtualizedViewManager,
  50. } from './virtualizedViewManager';
  51. function Chevron(props: {direction: 'up' | 'down' | 'left'}) {
  52. return (
  53. <svg
  54. viewBox="0 0 16 16"
  55. style={{
  56. transition: 'transform 120ms ease-in-out',
  57. transform: `rotate(${props.direction === 'up' ? 0 : props.direction === 'down' ? 180 : -90}deg)`,
  58. }}
  59. >
  60. <path d="M14,11.75a.74.74,0,0,1-.53-.22L8,6.06,2.53,11.53a.75.75,0,0,1-1.06-1.06l6-6a.75.75,0,0,1,1.06,0l6,6a.75.75,0,0,1,0,1.06A.74.74,0,0,1,14,11.75Z" />
  61. </svg>
  62. );
  63. }
  64. function Fire() {
  65. return (
  66. <svg viewBox="0 0 16 16">
  67. <path d="M8.08,15.92A6.58,6.58,0,0,1,1.51,9.34a4.88,4.88,0,0,1,2.2-4.25.74.74,0,0,1,1,.34,6,6,0,0,1,4-5.3A.74.74,0,0,1,9.4.22a.73.73,0,0,1,.33.61v.31A15.07,15.07,0,0,0,10,4.93a3.72,3.72,0,0,1,2.3-1.7.74.74,0,0,1,.66.12.75.75,0,0,1,.3.6A6.21,6.21,0,0,0,14,6.79a5.78,5.78,0,0,1,.68,2.55A6.58,6.58,0,0,1,8.08,15.92ZM3.59,7.23A4.25,4.25,0,0,0,3,9.34a5.07,5.07,0,1,0,10.14,0,4.6,4.6,0,0,0-.54-1.94,8,8,0,0,1-.76-2.32A2,2,0,0,0,11.07,7a.75.75,0,0,1-1.32.58C8.4,6,8.25,4.22,8.23,2c-2,1.29-2.15,3.58-2.09,5.85A7.52,7.52,0,0,1,6.14,9a.74.74,0,0,1-.46.63.77.77,0,0,1-.76-.11A4.56,4.56,0,0,1,3.59,7.23Z" />
  68. </svg>
  69. );
  70. }
  71. function Profile() {
  72. return (
  73. <svg viewBox="0 0 20 16">
  74. <path d="M15.25,0H.75C.33,0,0,.34,0,.75V5.59c0,.41,.34,.75,.75,.75h1.49v4.09c0,.41,.34,.75,.75,.75h1.73v4.09c0,.41,.34,.75,.75,.75h5.06c.41,0,.75-.34,.75-.75v-4.09h1.73c.41,0,.75-.34,.75-.75V6.34h1.49c.41,0,.75-.34,.75-.75V.75c0-.41-.34-.75-.75-.75Zm-5.47,14.52h-3.56v-3.34h3.56v3.34Zm2.48-4.84H3.74v-3.34H12.25v3.34Zm2.24-4.84H1.5V1.5H14.5v3.34Z" />
  75. </svg>
  76. );
  77. }
  78. function decodeScrollQueue(maybePath: unknown): TraceTree.NodePath[] | null {
  79. if (Array.isArray(maybePath)) {
  80. return maybePath;
  81. }
  82. if (typeof maybePath === 'string') {
  83. return [maybePath as TraceTree.NodePath];
  84. }
  85. return null;
  86. }
  87. const COUNT_FORMATTER = Intl.NumberFormat(undefined, {notation: 'compact'});
  88. const NO_ERRORS = new Set<TraceError>();
  89. const NO_PERFORMANCE_ISSUES = new Set<TracePerformanceIssue>();
  90. const NO_PROFILES = [];
  91. interface RovingTabIndexState {
  92. index: number | null;
  93. items: number | null;
  94. node: TraceTreeNode<TraceTree.NodeValue> | null;
  95. }
  96. function computeNextIndexFromAction(
  97. current_index: number,
  98. action: RovingTabIndexUserActions,
  99. items: number
  100. ): number {
  101. switch (action) {
  102. case 'next':
  103. if (current_index === items) {
  104. return 0;
  105. }
  106. return current_index + 1;
  107. case 'previous':
  108. if (current_index === 0) {
  109. return items;
  110. }
  111. return current_index - 1;
  112. case 'last':
  113. return items;
  114. case 'first':
  115. return 0;
  116. default:
  117. throw new TypeError(`Invalid or not implemented reducer action - ${action}`);
  118. }
  119. }
  120. function maybeFocusRow(
  121. ref: HTMLDivElement | null,
  122. node: TraceTreeNode<TraceTree.NodeValue>,
  123. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>
  124. ) {
  125. if (!ref) return;
  126. if (node === previouslyFocusedNodeRef.current) return;
  127. ref.focus();
  128. previouslyFocusedNodeRef.current = node;
  129. }
  130. interface TraceProps {
  131. manager: VirtualizedViewManager;
  132. onRowClick: (
  133. node: TraceTreeNode<TraceTree.NodeValue> | null,
  134. event: React.MouseEvent<HTMLElement> | null
  135. ) => void;
  136. onTraceSearch: (
  137. tree: TraceTree,
  138. query: string,
  139. node: TraceTreeNode<TraceTree.NodeValue> | null
  140. ) => void;
  141. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>;
  142. roving_dispatch: React.Dispatch<RovingTabIndexAction>;
  143. roving_state: RovingTabIndexState;
  144. scrollQueueRef: React.MutableRefObject<{
  145. eventId?: string;
  146. path?: TraceTree.NodePath[];
  147. } | null>;
  148. searchResultsIteratorIndex: number | null;
  149. searchResultsMap: Map<TraceTreeNode<TraceTree.NodeValue>, number>;
  150. search_dispatch: React.Dispatch<TraceSearchAction>;
  151. search_state: TraceSearchState;
  152. trace: TraceTree;
  153. trace_id: string;
  154. }
  155. function Trace({
  156. trace,
  157. trace_id,
  158. roving_state,
  159. roving_dispatch,
  160. search_state,
  161. search_dispatch,
  162. onRowClick,
  163. manager,
  164. scrollQueueRef,
  165. searchResultsIteratorIndex,
  166. searchResultsMap,
  167. previouslyFocusedNodeRef,
  168. onTraceSearch,
  169. }: TraceProps) {
  170. const theme = useTheme();
  171. const api = useApi();
  172. const {projects} = useProjects();
  173. const organization = useOrganization();
  174. const containerRef = useRef<HTMLDivElement | null>(null);
  175. const [_rerender, setRender] = useState(0);
  176. const treePromiseStatusRef =
  177. useRef<Map<TraceTreeNode<TraceTree.NodeValue>, 'loading' | 'error' | 'success'>>();
  178. if (!treePromiseStatusRef.current) {
  179. treePromiseStatusRef.current = new Map();
  180. }
  181. const treeRef = useRef<TraceTree>(trace);
  182. treeRef.current = trace;
  183. const searchStateRef = useRef<TraceSearchState>(search_state);
  184. searchStateRef.current = search_state;
  185. const rovingTabIndexStateRef = useRef<RovingTabIndexState>(roving_state);
  186. rovingTabIndexStateRef.current = roving_state;
  187. if (
  188. trace.root.space &&
  189. (trace.root.space[0] !== manager.to_origin ||
  190. trace.root.space[1] !== manager.trace_space.width)
  191. ) {
  192. manager.initializeTraceSpace([trace.root.space[0], 0, trace.root.space[1], 1]);
  193. const maybeQueue = decodeScrollQueue(qs.parse(location.search).node);
  194. const maybeEventId = qs.parse(location.search)?.eventId;
  195. if (maybeQueue || maybeEventId) {
  196. scrollQueueRef.current = {
  197. eventId: maybeEventId as string,
  198. path: maybeQueue as TraceTreeNode<TraceTree.NodeValue>['path'],
  199. };
  200. }
  201. }
  202. const loadedRef = useRef(false);
  203. useEffect(() => {
  204. if (loadedRef.current) {
  205. return;
  206. }
  207. if (trace.type !== 'trace' || !manager) {
  208. return;
  209. }
  210. loadedRef.current = true;
  211. if (!scrollQueueRef.current) {
  212. if (search_state.query) {
  213. onTraceSearch(treeRef.current, search_state.query, null);
  214. }
  215. return;
  216. }
  217. // Node path has higher specificity than eventId
  218. const promise = scrollQueueRef.current?.path
  219. ? manager.scrollToPath(
  220. trace,
  221. scrollQueueRef.current.path,
  222. () => setRender(a => (a + 1) % 2),
  223. {
  224. api,
  225. organization,
  226. }
  227. )
  228. : scrollQueueRef.current.eventId
  229. ? manager.scrollToEventID(
  230. scrollQueueRef?.current?.eventId,
  231. trace,
  232. () => setRender(a => (a + 1) % 2),
  233. {
  234. api,
  235. organization,
  236. }
  237. )
  238. : Promise.resolve(null);
  239. promise.then(maybeNode => {
  240. // Important to set scrollQueueRef.current to null and trigger a rerender
  241. // after the promise resolves as we show a loading state during scroll,
  242. // else the screen could jump around while we fetch span data
  243. scrollQueueRef.current = null;
  244. if (!maybeNode) {
  245. Sentry.captureMessage('Failled to find and scroll to node in tree');
  246. return;
  247. }
  248. if (maybeNode.node.space) {
  249. manager.animateViewTo(maybeNode.node.space);
  250. }
  251. onRowClick(maybeNode.node, null);
  252. roving_dispatch({
  253. type: 'set index',
  254. index: maybeNode.index,
  255. node: maybeNode.node,
  256. });
  257. manager.list?.scrollToRow(maybeNode.index, 'top');
  258. manager.scrollRowIntoViewHorizontally(maybeNode.node, 0, 12, 'exact');
  259. if (search_state.query) {
  260. onTraceSearch(treeRef.current, search_state.query, maybeNode.node);
  261. }
  262. });
  263. }, [
  264. api,
  265. scrollQueueRef,
  266. organization,
  267. trace,
  268. trace_id,
  269. manager,
  270. search_state.query,
  271. onTraceSearch,
  272. onRowClick,
  273. roving_dispatch,
  274. ]);
  275. const handleZoomIn = useCallback(
  276. (
  277. event: React.MouseEvent,
  278. node: TraceTreeNode<TraceTree.NodeValue>,
  279. value: boolean
  280. ) => {
  281. if (!isTransactionNode(node) && !isSpanNode(node)) {
  282. throw new TypeError('Node must be a transaction or span');
  283. }
  284. event.stopPropagation();
  285. setRender(a => (a + 1) % 2);
  286. treeRef.current
  287. .zoomIn(node, value, {
  288. api,
  289. organization,
  290. })
  291. .then(() => {
  292. setRender(a => (a + 1) % 2);
  293. if (search_state.query) {
  294. const previousNode =
  295. rovingTabIndexStateRef.current.node || searchStateRef.current.node;
  296. onTraceSearch(treeRef.current, search_state.query, previousNode);
  297. }
  298. treePromiseStatusRef.current!.set(node, 'success');
  299. })
  300. .catch(_e => {
  301. treePromiseStatusRef.current!.set(node, 'error');
  302. });
  303. },
  304. [api, organization, search_state, onTraceSearch]
  305. );
  306. const handleExpandNode = useCallback(
  307. (
  308. event: React.MouseEvent<Element>,
  309. node: TraceTreeNode<TraceTree.NodeValue>,
  310. value: boolean
  311. ) => {
  312. event.stopPropagation();
  313. treeRef.current.expand(node, value);
  314. setRender(a => (a + 1) % 2);
  315. if (search_state.query) {
  316. const previousNode =
  317. rovingTabIndexStateRef.current.node || searchStateRef.current.node;
  318. onTraceSearch(treeRef.current, search_state.query, previousNode);
  319. }
  320. },
  321. [search_state, onTraceSearch]
  322. );
  323. const onVirtulizedRowClick = useCallback(
  324. (
  325. event: React.MouseEvent<HTMLElement>,
  326. index: number,
  327. node: TraceTreeNode<TraceTree.NodeValue>
  328. ) => {
  329. previouslyFocusedNodeRef.current = node;
  330. const {eventId: _eventId, ...query} = qs.parse(location.search);
  331. browserHistory.replace({
  332. pathname: location.pathname,
  333. query: {
  334. ...query,
  335. node: node.path,
  336. },
  337. });
  338. onRowClick(node, event);
  339. roving_dispatch({type: 'set index', index, node});
  340. if (search_state.resultsLookup.has(node)) {
  341. const idx = search_state.resultsLookup.get(node)!;
  342. search_dispatch({
  343. type: 'set iterator index',
  344. resultIndex: index,
  345. resultIteratorIndex: idx,
  346. node,
  347. });
  348. } else {
  349. search_dispatch({type: 'clear iterator index'});
  350. }
  351. },
  352. [roving_dispatch, onRowClick, search_state, search_dispatch, previouslyFocusedNodeRef]
  353. );
  354. const onRowKeyDown = useCallback(
  355. (
  356. event: React.KeyboardEvent,
  357. index: number,
  358. node: TraceTreeNode<TraceTree.NodeValue>
  359. ) => {
  360. if (!manager.list) {
  361. return;
  362. }
  363. const action = getRovingIndexActionFromEvent(event);
  364. if (action) {
  365. event.preventDefault();
  366. const nextIndex = computeNextIndexFromAction(
  367. index,
  368. action,
  369. treeRef.current.list.length - 1
  370. );
  371. manager.scrollToRow(nextIndex);
  372. roving_dispatch({type: 'set index', index: nextIndex, node});
  373. const nextNode = treeRef.current.list[nextIndex];
  374. const offset =
  375. nextNode.depth >= node.depth ? manager.trace_physical_space.width / 2 : 0;
  376. if (manager.isOutsideOfViewOnKeyDown(trace.list[nextIndex], offset)) {
  377. manager.scrollRowIntoViewHorizontally(trace.list[nextIndex], 0, offset);
  378. }
  379. if (search_state.resultsLookup.has(trace.list[nextIndex])) {
  380. const idx = search_state.resultsLookup.get(trace.list[nextIndex])!;
  381. search_dispatch({
  382. type: 'set iterator index',
  383. resultIndex: nextIndex,
  384. resultIteratorIndex: idx,
  385. node,
  386. });
  387. } else {
  388. search_dispatch({type: 'clear iterator index'});
  389. }
  390. }
  391. },
  392. [manager, roving_dispatch, search_state, search_dispatch, trace.list]
  393. );
  394. // @TODO this is the implementation of infinite scroll. Once the user
  395. // reaches the end of the list, we fetch more data. The data is not yet
  396. // being appended to the tree as we need to figure out UX for this.
  397. // onRowsRendered callback should be passed to the List component
  398. // const limitRef = useRef<number | null>(null);
  399. // if (limitRef.current === null) {
  400. // let decodedLimit = getTraceQueryParams(qs.parse(location.search)).limit;
  401. // if (typeof decodedLimit === 'string') {
  402. // decodedLimit = parseInt(decodedLimit, 2);
  403. // }
  404. // limitRef.current = decodedLimit;
  405. // }
  406. // const loadMoreRequestRef =
  407. // useRef<Promise<TraceSplitResults<TraceFullDetailed> | null> | null>(null);
  408. // const onRowsRendered = useCallback((rows: RenderedRows) => {
  409. // if (loadMoreRequestRef.current) {
  410. // // in flight request
  411. // return;
  412. // }
  413. // if (rows.stopIndex !== treeRef.current.list.length - 1) {
  414. // // not at the end
  415. // return;
  416. // }
  417. // if (
  418. // !loadMoreRequestRef.current &&
  419. // limitRef.current &&
  420. // rows.stopIndex === treeRef.current.list.length - 1
  421. // ) {
  422. // limitRef.current = limitRef.current + 500;
  423. // const promise = fetchTrace(api, {
  424. // traceId: trace_id,
  425. // orgSlug: organization.slug,
  426. // query: qs.stringify(getTraceQueryParams(location, {limit: limitRef.current})),
  427. // })
  428. // .then(data => {
  429. // return data;
  430. // })
  431. // .catch(e => {
  432. // return e;
  433. // });
  434. // loadMoreRequestRef.current = promise;
  435. // }
  436. // }, []);
  437. const projectLookup: Record<string, PlatformKey | undefined> = useMemo(() => {
  438. return projects.reduce<Record<Project['slug'], Project['platform']>>(
  439. (acc, project) => {
  440. acc[project.slug] = project.platform;
  441. return acc;
  442. },
  443. {}
  444. );
  445. }, [projects]);
  446. const render = useCallback(
  447. (n: VirtualizedRow) => {
  448. return trace.type !== 'trace' || scrollQueueRef.current ? (
  449. <RenderPlaceholderRow
  450. key={n.key}
  451. index={n.index}
  452. style={n.style}
  453. node={n.item}
  454. theme={theme}
  455. projects={projectLookup}
  456. manager={manager}
  457. />
  458. ) : (
  459. <RenderRow
  460. key={n.key}
  461. index={n.index}
  462. organization={organization}
  463. previouslyFocusedNodeRef={previouslyFocusedNodeRef}
  464. tabIndex={roving_state.index ?? -1}
  465. isSearchResult={searchResultsMap.has(n.item)}
  466. searchResultsIteratorIndex={searchResultsIteratorIndex}
  467. style={n.style}
  468. trace_id={trace_id}
  469. projects={projectLookup}
  470. node={n.item}
  471. manager={manager}
  472. theme={theme}
  473. onExpand={handleExpandNode}
  474. onZoomIn={handleZoomIn}
  475. onRowClick={onVirtulizedRowClick}
  476. onRowKeyDown={onRowKeyDown}
  477. />
  478. );
  479. },
  480. // we add _rerender as a dependency to trigger the virtualized list rerender
  481. // eslint-disable-next-line react-hooks/exhaustive-deps
  482. [
  483. handleExpandNode,
  484. handleZoomIn,
  485. manager,
  486. onVirtulizedRowClick,
  487. onRowKeyDown,
  488. organization,
  489. projectLookup,
  490. roving_state.index,
  491. searchResultsIteratorIndex,
  492. searchResultsMap,
  493. theme,
  494. trace_id,
  495. trace.type,
  496. _rerender,
  497. ]
  498. );
  499. const [scrollContainer, setScrollContainer] = useState<HTMLElement | null>(null);
  500. const virtualizedList = useVirtualizedList({
  501. manager,
  502. items: trace.list,
  503. container: scrollContainer,
  504. render,
  505. });
  506. return (
  507. <TraceStylingWrapper
  508. ref={r => {
  509. containerRef.current = r;
  510. manager.onContainerRef(r);
  511. }}
  512. className={`${trace.indicators.length > 0 ? 'WithIndicators' : ''} ${trace.type !== 'trace' || scrollQueueRef.current ? 'Loading' : ''}`}
  513. >
  514. <div className="TraceDivider" ref={r => manager?.registerDividerRef(r)} />
  515. <div
  516. className="TraceIndicatorContainer"
  517. ref={r => manager.registerIndicatorContainerRef(r)}
  518. >
  519. {trace.indicators.length > 0
  520. ? trace.indicators.map((indicator, i) => {
  521. return (
  522. <div
  523. key={i}
  524. ref={r => manager.registerIndicatorRef(r, i, indicator)}
  525. className={`TraceIndicator ${indicator.poor ? 'Errored' : ''}`}
  526. >
  527. <div className="TraceIndicatorLabel">{indicator.label}</div>
  528. <div className="TraceIndicatorLine" />
  529. </div>
  530. );
  531. })
  532. : null}
  533. {manager.interval_bars.map((_, i) => {
  534. const indicatorTimestamp = manager.intervals[i] ?? 0;
  535. const timestamp = manager.to_origin + indicatorTimestamp;
  536. if (trace.type !== 'trace') {
  537. return null;
  538. }
  539. return (
  540. <div
  541. key={i}
  542. ref={r => manager.registerTimelineIndicatorRef(r, i)}
  543. className="TraceIndicator Timeline"
  544. style={{
  545. transform: `translate(${manager.computeTransformXFromTimestamp(timestamp)}px, 0)`,
  546. }}
  547. >
  548. <div className="TraceIndicatorLabel">
  549. {indicatorTimestamp > 0
  550. ? getDuration(
  551. (manager.trace_view.x + indicatorTimestamp) / 1000,
  552. 2,
  553. true
  554. )
  555. : '0s'}
  556. </div>
  557. <div className="TraceIndicatorLine" />
  558. </div>
  559. );
  560. })}
  561. </div>
  562. <div ref={r => setScrollContainer(r)}>
  563. <div>{virtualizedList.rendered}</div>
  564. </div>
  565. </TraceStylingWrapper>
  566. );
  567. }
  568. export default Trace;
  569. function RenderRow(props: {
  570. index: number;
  571. isSearchResult: boolean;
  572. manager: VirtualizedViewManager;
  573. node: TraceTreeNode<TraceTree.NodeValue>;
  574. onExpand: (
  575. event: React.MouseEvent<Element>,
  576. node: TraceTreeNode<TraceTree.NodeValue>,
  577. value: boolean
  578. ) => void;
  579. onRowClick: (
  580. event: React.MouseEvent<HTMLElement>,
  581. index: number,
  582. node: TraceTreeNode<TraceTree.NodeValue>
  583. ) => void;
  584. onRowKeyDown: (
  585. event: React.KeyboardEvent,
  586. index: number,
  587. node: TraceTreeNode<TraceTree.NodeValue>
  588. ) => void;
  589. onZoomIn: (
  590. event: React.MouseEvent<Element>,
  591. node: TraceTreeNode<TraceTree.NodeValue>,
  592. value: boolean
  593. ) => void;
  594. organization: Organization;
  595. previouslyFocusedNodeRef: React.MutableRefObject<TraceTreeNode<TraceTree.NodeValue> | null>;
  596. projects: Record<Project['slug'], Project['platform']>;
  597. searchResultsIteratorIndex: number | null;
  598. style: React.CSSProperties;
  599. tabIndex: number;
  600. theme: Theme;
  601. trace_id: string;
  602. }) {
  603. const virtualized_index = props.index - props.manager.start_virtualized_index;
  604. if (!props.node.value) {
  605. return null;
  606. }
  607. const rowSearchClassName = `${props.isSearchResult ? 'SearchResult' : ''} ${props.searchResultsIteratorIndex === props.index ? 'Highlight' : ''}`;
  608. if (isAutogroupedNode(props.node)) {
  609. return (
  610. <div
  611. key={props.index}
  612. ref={r =>
  613. props.tabIndex === props.index
  614. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  615. : null
  616. }
  617. tabIndex={props.tabIndex === props.index ? 0 : -1}
  618. className={`Autogrouped TraceRow ${rowSearchClassName} ${props.node.has_errors ? 'Errored' : ''}`}
  619. onClick={e => props.onRowClick(e, props.index, props.node)}
  620. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  621. style={{
  622. top: props.style.top,
  623. height: props.style.height,
  624. }}
  625. >
  626. <div
  627. className="TraceLeftColumn"
  628. ref={r =>
  629. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  630. }
  631. style={{
  632. width: props.manager.columns.list.width * 100 + '%',
  633. }}
  634. >
  635. <div
  636. className={`TraceLeftColumnInner`}
  637. style={{
  638. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  639. }}
  640. >
  641. <div className="TraceChildrenCountWrapper">
  642. <Connectors node={props.node} manager={props.manager} />
  643. <ChildrenButton
  644. icon={
  645. props.node.expanded ? (
  646. <Chevron direction="up" />
  647. ) : (
  648. <Chevron direction="down" />
  649. )
  650. }
  651. status={props.node.fetchStatus}
  652. expanded={!props.node.expanded}
  653. onClick={e => props.onExpand(e, props.node, !props.node.expanded)}
  654. errored={props.node.has_errors}
  655. >
  656. {COUNT_FORMATTER.format(props.node.groupCount)}
  657. </ChildrenButton>
  658. </div>
  659. <span className="TraceOperation">{t('Autogrouped')}</span>
  660. <strong className="TraceEmDash"> — </strong>
  661. <span className="TraceDescription">{props.node.value.autogrouped_by.op}</span>
  662. </div>
  663. </div>
  664. <div
  665. className={`TraceRightColumn ${props.index % 2 === 0 ? 0 : 'Odd'}`}
  666. ref={r =>
  667. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  668. }
  669. style={{
  670. width: props.manager.columns.span_list.width * 100 + '%',
  671. }}
  672. onDoubleClick={e => {
  673. e.stopPropagation();
  674. props.manager.onZoomIntoSpace(props.node.space!);
  675. }}
  676. >
  677. <AutogroupedTraceBar
  678. virtualized_index={virtualized_index}
  679. manager={props.manager}
  680. color={makeTraceNodeBarColor(props.theme, props.node)}
  681. entire_space={props.node.space}
  682. node_spaces={props.node.autogroupedSegments}
  683. errors={props.node.errors}
  684. performance_issues={props.node.performance_issues}
  685. profiles={props.node.profiles}
  686. />
  687. <button
  688. ref={ref =>
  689. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  690. }
  691. className="TraceArrow"
  692. onClick={_e => {
  693. props.manager.onBringRowIntoView(props.node.space!);
  694. }}
  695. >
  696. <Chevron direction="left" />
  697. </button>
  698. </div>
  699. </div>
  700. );
  701. }
  702. if (isTransactionNode(props.node)) {
  703. const errored =
  704. props.node.value.errors.length > 0 ||
  705. props.node.value.performance_issues.length > 0;
  706. return (
  707. <div
  708. key={props.index}
  709. ref={r =>
  710. props.tabIndex === props.index
  711. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  712. : null
  713. }
  714. tabIndex={props.tabIndex === props.index ? 0 : -1}
  715. className={`TraceRow ${rowSearchClassName} ${errored ? 'Errored' : ''}`}
  716. onClick={e => props.onRowClick(e, props.index, props.node)}
  717. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  718. style={{
  719. top: props.style.top,
  720. height: props.style.height,
  721. }}
  722. >
  723. <div
  724. className="TraceLeftColumn"
  725. ref={r =>
  726. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  727. }
  728. style={{
  729. width: props.manager.columns.list.width * 100 + '%',
  730. }}
  731. >
  732. <div
  733. className={`TraceLeftColumnInner`}
  734. style={{
  735. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  736. }}
  737. >
  738. <div
  739. className={`TraceChildrenCountWrapper ${
  740. props.node.isOrphaned ? 'Orphaned' : ''
  741. }
  742. `}
  743. >
  744. <Connectors node={props.node} manager={props.manager} />
  745. {props.node.children.length > 0 || props.node.canFetch ? (
  746. <ChildrenButton
  747. icon={
  748. props.node.canFetch && props.node.fetchStatus === 'idle' ? (
  749. '+'
  750. ) : props.node.canFetch && props.node.zoomedIn ? (
  751. <Chevron direction="down" />
  752. ) : (
  753. '+'
  754. )
  755. }
  756. status={props.node.fetchStatus}
  757. expanded={props.node.expanded || props.node.zoomedIn}
  758. onClick={e =>
  759. props.node.canFetch
  760. ? props.onZoomIn(e, props.node, !props.node.zoomedIn)
  761. : props.onExpand(e, props.node, !props.node.expanded)
  762. }
  763. errored={errored}
  764. >
  765. {props.node.children.length > 0
  766. ? COUNT_FORMATTER.format(props.node.children.length)
  767. : null}
  768. </ChildrenButton>
  769. ) : null}
  770. </div>
  771. <PlatformIcon
  772. platform={props.projects[props.node.value.project_slug] ?? 'default'}
  773. />
  774. <span className="TraceOperation">{props.node.value['transaction.op']}</span>
  775. <strong className="TraceEmDash"> — </strong>
  776. <span>{props.node.value.transaction}</span>
  777. </div>
  778. </div>
  779. <div
  780. ref={r =>
  781. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  782. }
  783. className={`TraceRightColumn ${props.index % 2 === 0 ? 0 : 'Odd'}`}
  784. style={{
  785. width: props.manager.columns.span_list.width * 100 + '%',
  786. }}
  787. onDoubleClick={e => {
  788. e.stopPropagation();
  789. props.manager.onZoomIntoSpace(props.node.space!);
  790. }}
  791. >
  792. <TraceBar
  793. virtualized_index={virtualized_index}
  794. manager={props.manager}
  795. color={makeTraceNodeBarColor(props.theme, props.node)}
  796. node_space={props.node.space}
  797. errors={props.node.errors}
  798. performance_issues={props.node.performance_issues}
  799. profiles={props.node.profiles}
  800. />
  801. <button
  802. ref={ref =>
  803. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  804. }
  805. className="TraceArrow"
  806. onClick={_e => {
  807. props.manager.onBringRowIntoView(props.node.space!);
  808. }}
  809. >
  810. <Chevron direction="left" />
  811. </button>
  812. </div>
  813. </div>
  814. );
  815. }
  816. if (isSpanNode(props.node)) {
  817. const errored = props.node.errors.size > 0 || props.node.performance_issues.size > 0;
  818. return (
  819. <div
  820. key={props.index}
  821. ref={r =>
  822. props.tabIndex === props.index
  823. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  824. : null
  825. }
  826. tabIndex={props.tabIndex === props.index ? 0 : -1}
  827. className={`TraceRow ${rowSearchClassName} ${errored ? 'Errored' : ''}`}
  828. onClick={e => props.onRowClick(e, props.index, props.node)}
  829. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  830. style={{
  831. top: props.style.top,
  832. height: props.style.height,
  833. }}
  834. >
  835. <div
  836. className="TraceLeftColumn"
  837. ref={r =>
  838. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  839. }
  840. style={{
  841. width: props.manager.columns.list.width * 100 + '%',
  842. }}
  843. >
  844. <div
  845. className={`TraceLeftColumnInner`}
  846. style={{
  847. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  848. }}
  849. >
  850. <div
  851. className={`TraceChildrenCountWrapper ${
  852. props.node.isOrphaned ? 'Orphaned' : ''
  853. }`}
  854. >
  855. <Connectors node={props.node} manager={props.manager} />
  856. {props.node.children.length > 0 || props.node.canFetch ? (
  857. <ChildrenButton
  858. icon={
  859. props.node.canFetch ? (
  860. '+'
  861. ) : props.node.expanded ? (
  862. <Chevron direction="up" />
  863. ) : (
  864. <Chevron direction="down" />
  865. )
  866. }
  867. status={props.node.fetchStatus}
  868. expanded={props.node.expanded || props.node.zoomedIn}
  869. onClick={e =>
  870. props.node.canFetch
  871. ? props.onZoomIn(e, props.node, !props.node.zoomedIn)
  872. : props.onExpand(e, props.node, !props.node.expanded)
  873. }
  874. errored={errored}
  875. >
  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">{props.node.value.op ?? '<unknown>'}</span>
  883. <strong className="TraceEmDash"> — </strong>
  884. <span className="TraceDescription" title={props.node.value.description}>
  885. {!props.node.value.description
  886. ? 'unknown'
  887. : props.node.value.description.length > 100
  888. ? props.node.value.description.slice(0, 100).trim() + '\u2026'
  889. : props.node.value.description}
  890. </span>
  891. </div>
  892. </div>
  893. <div
  894. ref={r =>
  895. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  896. }
  897. className={`TraceRightColumn ${props.index % 2 === 0 ? 0 : 'Odd'}`}
  898. style={{
  899. width: props.manager.columns.span_list.width * 100 + '%',
  900. }}
  901. onDoubleClick={e => {
  902. e.stopPropagation();
  903. props.manager.onZoomIntoSpace(props.node.space!);
  904. }}
  905. >
  906. <TraceBar
  907. virtualized_index={virtualized_index}
  908. manager={props.manager}
  909. color={makeTraceNodeBarColor(props.theme, props.node)}
  910. node_space={props.node.space}
  911. errors={props.node.errors}
  912. performance_issues={props.node.performance_issues}
  913. profiles={NO_PROFILES}
  914. />
  915. <button
  916. ref={ref =>
  917. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  918. }
  919. className="TraceArrow"
  920. onClick={_e => {
  921. props.manager.onBringRowIntoView(props.node.space!);
  922. }}
  923. >
  924. <Chevron direction="left" />
  925. </button>
  926. </div>
  927. </div>
  928. );
  929. }
  930. if (isMissingInstrumentationNode(props.node)) {
  931. return (
  932. <div
  933. key={props.index}
  934. ref={r =>
  935. props.tabIndex === props.index
  936. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  937. : null
  938. }
  939. tabIndex={props.tabIndex === props.index ? 0 : -1}
  940. className={`TraceRow ${rowSearchClassName}`}
  941. onClick={e => props.onRowClick(e, props.index, props.node)}
  942. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  943. style={{
  944. top: props.style.top,
  945. height: props.style.height,
  946. }}
  947. >
  948. <div
  949. className="TraceLeftColumn"
  950. ref={r =>
  951. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  952. }
  953. style={{
  954. width: props.manager.columns.list.width * 100 + '%',
  955. }}
  956. >
  957. <div
  958. className="TraceLeftColumnInner"
  959. style={{
  960. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  961. }}
  962. >
  963. <div className="TraceChildrenCountWrapper">
  964. <Connectors node={props.node} manager={props.manager} />
  965. </div>
  966. <span className="TraceOperation">{t('Missing instrumentation')}</span>
  967. </div>
  968. </div>
  969. <div
  970. ref={r =>
  971. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  972. }
  973. className={`TraceRightColumn ${props.index % 2 === 0 ? 0 : 'Odd'}`}
  974. style={{
  975. width: props.manager.columns.span_list.width * 100 + '%',
  976. }}
  977. onDoubleClick={e => {
  978. e.stopPropagation();
  979. props.manager.onZoomIntoSpace(props.node.space!);
  980. }}
  981. >
  982. <TraceBar
  983. virtualized_index={virtualized_index}
  984. manager={props.manager}
  985. color={makeTraceNodeBarColor(props.theme, props.node)}
  986. node_space={props.node.space}
  987. performance_issues={NO_PERFORMANCE_ISSUES}
  988. profiles={NO_PROFILES}
  989. errors={NO_ERRORS}
  990. />
  991. <button
  992. ref={ref =>
  993. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  994. }
  995. className="TraceArrow"
  996. onClick={_e => {
  997. props.manager.onBringRowIntoView(props.node.space!);
  998. }}
  999. >
  1000. <Chevron direction="left" />
  1001. </button>
  1002. </div>
  1003. </div>
  1004. );
  1005. }
  1006. if (isTraceNode(props.node)) {
  1007. return (
  1008. <div
  1009. key={props.index}
  1010. ref={r =>
  1011. props.tabIndex === props.index
  1012. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  1013. : null
  1014. }
  1015. tabIndex={props.tabIndex === props.index ? 0 : -1}
  1016. className={`TraceRow ${rowSearchClassName} ${props.node.has_errors ? 'Errored' : ''}`}
  1017. onClick={e => props.onRowClick(e, props.index, props.node)}
  1018. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  1019. style={{
  1020. top: props.style.top,
  1021. height: props.style.height,
  1022. }}
  1023. >
  1024. <div
  1025. className="TraceLeftColumn"
  1026. ref={r =>
  1027. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  1028. }
  1029. style={{
  1030. width: props.manager.columns.list.width * 100 + '%',
  1031. }}
  1032. >
  1033. <div
  1034. className="TraceLeftColumnInner"
  1035. style={{
  1036. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  1037. }}
  1038. >
  1039. <div className="TraceChildrenCountWrapper Root">
  1040. <Connectors node={props.node} manager={props.manager} />
  1041. {props.node.children.length > 0 || props.node.canFetch ? (
  1042. <ChildrenButton icon={''} status={'idle'} expanded onClick={() => void 0}>
  1043. {props.node.children.length > 0
  1044. ? COUNT_FORMATTER.format(props.node.children.length)
  1045. : null}
  1046. </ChildrenButton>
  1047. ) : null}
  1048. </div>
  1049. <span className="TraceOperation">{t('Trace')}</span>
  1050. <strong className="TraceEmDash"> — </strong>
  1051. <span className="TraceDescription">{props.trace_id}</span>
  1052. </div>
  1053. </div>
  1054. <div
  1055. ref={r =>
  1056. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  1057. }
  1058. className={`TraceRightColumn ${props.index % 2 === 0 ? 0 : 'Odd'}`}
  1059. style={{
  1060. width: props.manager.columns.span_list.width * 100 + '%',
  1061. }}
  1062. onDoubleClick={e => {
  1063. e.stopPropagation();
  1064. props.manager.onZoomIntoSpace(props.node.space!);
  1065. }}
  1066. >
  1067. <TraceBar
  1068. virtualized_index={virtualized_index}
  1069. manager={props.manager}
  1070. color={makeTraceNodeBarColor(props.theme, props.node)}
  1071. node_space={props.node.space}
  1072. errors={NO_ERRORS}
  1073. performance_issues={NO_PERFORMANCE_ISSUES}
  1074. profiles={NO_PROFILES}
  1075. />
  1076. <button
  1077. ref={ref =>
  1078. props.manager.registerArrowRef(ref, props.node.space!, virtualized_index)
  1079. }
  1080. className="TraceArrow"
  1081. onClick={_e => {
  1082. props.manager.onBringRowIntoView(props.node.space!);
  1083. }}
  1084. >
  1085. <Chevron direction="left" />
  1086. </button>
  1087. </div>
  1088. </div>
  1089. );
  1090. }
  1091. if (isTraceErrorNode(props.node)) {
  1092. return (
  1093. <div
  1094. key={props.index}
  1095. ref={r =>
  1096. props.tabIndex === props.index
  1097. ? maybeFocusRow(r, props.node, props.previouslyFocusedNodeRef)
  1098. : null
  1099. }
  1100. tabIndex={props.tabIndex === props.index ? 0 : -1}
  1101. className={`TraceRow ${rowSearchClassName} Errored`}
  1102. onClick={e => props.onRowClick(e, props.index, props.node)}
  1103. onKeyDown={event => props.onRowKeyDown(event, props.index, props.node)}
  1104. style={{
  1105. top: props.style.top,
  1106. height: props.style.height,
  1107. }}
  1108. >
  1109. <div
  1110. className="TraceLeftColumn"
  1111. ref={r =>
  1112. props.manager.registerColumnRef('list', r, virtualized_index, props.node)
  1113. }
  1114. style={{
  1115. width: props.manager.columns.list.width * 100 + '%',
  1116. }}
  1117. >
  1118. <div
  1119. className="TraceLeftColumnInner"
  1120. style={{
  1121. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  1122. }}
  1123. >
  1124. <div className="TraceChildrenCountWrapper">
  1125. <Connectors node={props.node} manager={props.manager} />
  1126. </div>
  1127. <PlatformIcon
  1128. platform={props.projects[props.node.value.project_slug] ?? 'default'}
  1129. />
  1130. <span className="TraceOperation">{t('Error')}</span>
  1131. <strong className="TraceEmDash"> — </strong>
  1132. <span className="TraceDescription">{props.node.value.title}</span>
  1133. </div>
  1134. </div>
  1135. <div
  1136. ref={r =>
  1137. props.manager.registerColumnRef('span_list', r, virtualized_index, props.node)
  1138. }
  1139. className={`TraceRightColumn ${props.index % 2 === 0 ? 0 : 'Odd'}`}
  1140. style={{
  1141. width: props.manager.columns.span_list.width * 100 + '%',
  1142. }}
  1143. onDoubleClick={e => {
  1144. e.stopPropagation();
  1145. props.manager.onZoomIntoSpace(props.node.space!);
  1146. }}
  1147. >
  1148. <InvisibleTraceBar
  1149. node_space={props.node.space}
  1150. manager={props.manager}
  1151. virtualizedIndex={virtualized_index}
  1152. >
  1153. {typeof props.node.value.timestamp === 'number' ? (
  1154. <div className="TraceError">
  1155. <Fire />
  1156. </div>
  1157. ) : null}
  1158. </InvisibleTraceBar>
  1159. </div>
  1160. </div>
  1161. );
  1162. }
  1163. return null;
  1164. }
  1165. function RenderPlaceholderRow(props: {
  1166. index: number;
  1167. manager: VirtualizedViewManager;
  1168. node: TraceTreeNode<TraceTree.NodeValue>;
  1169. projects: Record<Project['slug'], Project['platform']>;
  1170. style: React.CSSProperties;
  1171. theme: Theme;
  1172. }) {
  1173. return (
  1174. <div
  1175. key={props.index}
  1176. className="TraceRow"
  1177. style={{
  1178. top: props.style.top,
  1179. height: props.style.height,
  1180. pointerEvents: 'none',
  1181. color: props.theme.subText,
  1182. paddingLeft: 8,
  1183. }}
  1184. >
  1185. <div
  1186. className="TraceLeftColumn"
  1187. style={{width: props.manager.columns.list.width * 100 + '%'}}
  1188. >
  1189. <div
  1190. className="TraceLeftColumnInner"
  1191. style={{
  1192. paddingLeft: props.node.depth * props.manager.row_depth_padding,
  1193. }}
  1194. >
  1195. <div
  1196. className={`TraceChildrenCountWrapper ${isTraceNode(props.node) ? 'Root' : ''}`}
  1197. >
  1198. <Connectors node={props.node} manager={props.manager} />
  1199. {props.node.children.length > 0 || props.node.canFetch ? (
  1200. <ChildrenButton
  1201. icon="+"
  1202. status={props.node.fetchStatus}
  1203. expanded={props.node.expanded || props.node.zoomedIn}
  1204. onClick={() => void 0}
  1205. >
  1206. {props.node.children.length > 0
  1207. ? COUNT_FORMATTER.format(props.node.children.length)
  1208. : null}
  1209. </ChildrenButton>
  1210. ) : null}
  1211. </div>
  1212. <Placeholder
  1213. className="Placeholder"
  1214. height="12px"
  1215. width={randomBetween(20, 80) + '%'}
  1216. style={{
  1217. transition: 'all 30s ease-out',
  1218. }}
  1219. />
  1220. </div>
  1221. </div>
  1222. <div
  1223. className={`TraceRightColumn ${props.index % 2 === 0 ? 0 : 'Odd'}`}
  1224. style={{
  1225. width: props.manager.columns.span_list.width * 100 + '%',
  1226. backgroundColor:
  1227. props.index % 2 === 0 ? props.theme.backgroundSecondary : undefined,
  1228. }}
  1229. >
  1230. <Placeholder
  1231. className="Placeholder"
  1232. height="12px"
  1233. width={randomBetween(20, 80) + '%'}
  1234. style={{
  1235. transition: 'all 30s ease-out',
  1236. transform: `translate(${randomBetween(0, 200) + 'px'}, 0)`,
  1237. }}
  1238. />
  1239. </div>
  1240. </div>
  1241. );
  1242. }
  1243. function randomBetween(min: number, max: number) {
  1244. return Math.floor(Math.random() * (max - min + 1) + min);
  1245. }
  1246. function Connectors(props: {
  1247. manager: VirtualizedViewManager;
  1248. node: TraceTreeNode<TraceTree.NodeValue>;
  1249. }) {
  1250. const showVerticalConnector =
  1251. ((props.node.expanded || props.node.zoomedIn) && props.node.children.length > 0) ||
  1252. (props.node.value && isParentAutogroupedNode(props.node));
  1253. // If the tail node of the collapsed node has no children,
  1254. // we don't want to render the vertical connector as no children
  1255. // are being rendered as the chain is entirely collapsed
  1256. const hideVerticalConnector =
  1257. showVerticalConnector &&
  1258. props.node.value &&
  1259. props.node instanceof ParentAutogroupNode &&
  1260. !props.node.tail.children.length;
  1261. return (
  1262. <Fragment>
  1263. {props.node.connectors.map((c, i) => {
  1264. return (
  1265. <div
  1266. key={i}
  1267. style={{
  1268. left: -(
  1269. Math.abs(Math.abs(c) - props.node.depth) * props.manager.row_depth_padding
  1270. ),
  1271. }}
  1272. className={`TraceVerticalConnector ${c < 0 ? 'Orphaned' : ''}`}
  1273. />
  1274. );
  1275. })}
  1276. {showVerticalConnector && !hideVerticalConnector ? (
  1277. <div className="TraceExpandedVerticalConnector" />
  1278. ) : null}
  1279. {props.node.isLastChild ? (
  1280. <div className="TraceVerticalLastChildConnector" />
  1281. ) : (
  1282. <div className="TraceVerticalConnector" />
  1283. )}
  1284. </Fragment>
  1285. );
  1286. }
  1287. function ChildrenButton(props: {
  1288. children: React.ReactNode;
  1289. expanded: boolean;
  1290. icon: React.ReactNode;
  1291. onClick: (e: React.MouseEvent) => void;
  1292. status: TraceTreeNode<any>['fetchStatus'] | undefined;
  1293. errored?: boolean;
  1294. }) {
  1295. return (
  1296. <button
  1297. className={`TraceChildrenCount ${props.errored ? 'Errored' : ''}`}
  1298. onClick={props.onClick}
  1299. >
  1300. <div className="TraceChildrenCountContent">{props.children}</div>
  1301. <div className="TraceChildrenCountAction">
  1302. {props.icon}
  1303. {props.status === 'loading' ? (
  1304. <LoadingIndicator className="TraceActionsLoadingIndicator" size={8} />
  1305. ) : null}
  1306. </div>
  1307. </button>
  1308. );
  1309. }
  1310. interface TraceBarProps {
  1311. color: string;
  1312. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1313. manager: VirtualizedViewManager;
  1314. node_space: [number, number] | null;
  1315. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1316. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1317. virtualized_index: number;
  1318. }
  1319. function TraceBar(props: TraceBarProps) {
  1320. if (!props.node_space) {
  1321. return null;
  1322. }
  1323. const duration = getDuration(props.node_space[1] / 1000, 2, true);
  1324. const spanTransform = props.manager.computeSpanCSSMatrixTransform(props.node_space);
  1325. const [inside, textTransform] = props.manager.computeSpanTextPlacement(
  1326. props.node_space,
  1327. duration
  1328. );
  1329. return (
  1330. <Fragment>
  1331. <div
  1332. ref={r =>
  1333. props.manager.registerSpanBarRef(r, props.node_space!, props.virtualized_index)
  1334. }
  1335. className="TraceBar"
  1336. style={
  1337. {
  1338. transform: `matrix(${spanTransform.join(',')})`,
  1339. '--inverse-span-scale': 1 / spanTransform[0],
  1340. backgroundColor: props.color,
  1341. // unknown css variables cannot be part of the style object
  1342. } as React.CSSProperties
  1343. }
  1344. >
  1345. {props.profiles.length > 0 ? (
  1346. <Profiles
  1347. node_space={props.node_space}
  1348. profiles={props.profiles}
  1349. manager={props.manager}
  1350. />
  1351. ) : null}
  1352. {props.errors.size > 0 ? (
  1353. <Errors
  1354. node_space={props.node_space}
  1355. errors={props.errors}
  1356. manager={props.manager}
  1357. />
  1358. ) : null}
  1359. {props.performance_issues.size > 0 ? (
  1360. <PerformanceIssues
  1361. node_space={props.node_space}
  1362. performance_issues={props.performance_issues}
  1363. manager={props.manager}
  1364. />
  1365. ) : null}
  1366. </div>
  1367. <div
  1368. ref={r =>
  1369. props.manager.registerSpanBarTextRef(
  1370. r,
  1371. duration,
  1372. props.node_space!,
  1373. props.virtualized_index
  1374. )
  1375. }
  1376. className="TraceBarDuration"
  1377. style={{
  1378. color: inside ? 'white' : '',
  1379. transform: `translate(${textTransform ?? 0}px, 0)`,
  1380. }}
  1381. >
  1382. {duration}
  1383. </div>
  1384. </Fragment>
  1385. );
  1386. }
  1387. interface InvisibleTraceBarProps {
  1388. children: React.ReactNode;
  1389. manager: VirtualizedViewManager;
  1390. node_space: [number, number] | null;
  1391. virtualizedIndex: number;
  1392. }
  1393. function InvisibleTraceBar(props: InvisibleTraceBarProps) {
  1394. if (!props.node_space || !props.children) {
  1395. return null;
  1396. }
  1397. const transform = `translateX(${props.manager.computeTransformXFromTimestamp(props.node_space[0])}px)`;
  1398. return (
  1399. <div
  1400. ref={r =>
  1401. props.manager.registerInvisibleBarRef(
  1402. r,
  1403. props.node_space!,
  1404. props.virtualizedIndex
  1405. )
  1406. }
  1407. className="TraceBar Invisible"
  1408. style={{
  1409. transform,
  1410. }}
  1411. onDoubleClick={e => {
  1412. e.stopPropagation();
  1413. props.manager.onZoomIntoSpace(props.node_space!);
  1414. }}
  1415. >
  1416. {props.children}
  1417. </div>
  1418. );
  1419. }
  1420. interface PerformanceIssuesProps {
  1421. manager: VirtualizedViewManager;
  1422. node_space: [number, number] | null;
  1423. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1424. }
  1425. function PerformanceIssues(props: PerformanceIssuesProps) {
  1426. const performance_issues = useMemo(() => {
  1427. return [...props.performance_issues];
  1428. }, [props.performance_issues]);
  1429. if (!props.performance_issues.size) {
  1430. return null;
  1431. }
  1432. return (
  1433. <Fragment>
  1434. {performance_issues.map((issue, _i) => {
  1435. const timestamp = issue.start * 1e3;
  1436. // Clamp the issue timestamp to the span's timestamp
  1437. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1438. clamp(
  1439. timestamp,
  1440. props.node_space![0],
  1441. props.node_space![0] + props.node_space![1]
  1442. ),
  1443. props.node_space!
  1444. );
  1445. const max_width = 100 - left;
  1446. const issue_duration = (issue.end - issue.start) * 1e3;
  1447. const width = clamp((issue_duration / props.node_space![1]) * 100, 0, max_width);
  1448. return (
  1449. <div
  1450. key={issue.event_id}
  1451. className="TracePerformanceIssue"
  1452. style={{left: left * 100 + '%', width: width + '%'}}
  1453. >
  1454. <div className="TraceError" style={{left: 0}}>
  1455. <Fire />
  1456. </div>
  1457. </div>
  1458. );
  1459. })}
  1460. </Fragment>
  1461. );
  1462. }
  1463. interface ErrorsProps {
  1464. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1465. manager: VirtualizedViewManager;
  1466. node_space: [number, number] | null;
  1467. }
  1468. function Errors(props: ErrorsProps) {
  1469. const errors = useMemo(() => {
  1470. return [...props.errors];
  1471. }, [props.errors]);
  1472. if (!props.errors.size) {
  1473. return null;
  1474. }
  1475. return (
  1476. <Fragment>
  1477. {errors.map((error, _i) => {
  1478. const timestamp = error.timestamp ? error.timestamp * 1e3 : props.node_space![0];
  1479. // Clamp the error timestamp to the span's timestamp
  1480. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1481. clamp(
  1482. timestamp,
  1483. props.node_space![0],
  1484. props.node_space![0] + props.node_space![1]
  1485. ),
  1486. props.node_space!
  1487. );
  1488. return (
  1489. <div
  1490. key={error.event_id}
  1491. className="TraceError"
  1492. style={{left: left * 100 + '%'}}
  1493. >
  1494. <Fire />
  1495. </div>
  1496. );
  1497. })}
  1498. </Fragment>
  1499. );
  1500. }
  1501. interface ProfilesProps {
  1502. manager: VirtualizedViewManager;
  1503. node_space: [number, number] | null;
  1504. profiles: TraceTree.Profile[];
  1505. }
  1506. function Profiles(props: ProfilesProps) {
  1507. if (!props.profiles.length) {
  1508. return null;
  1509. }
  1510. return (
  1511. <Fragment>
  1512. {props.profiles.map((profile, _i) => {
  1513. const timestamp = profile.space[0];
  1514. // Clamp the profile timestamp to the span's timestamp
  1515. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1516. clamp(
  1517. timestamp,
  1518. props.node_space![0],
  1519. props.node_space![0] + props.node_space![1]
  1520. ),
  1521. props.node_space!
  1522. );
  1523. return (
  1524. <div
  1525. key={profile.profile_id}
  1526. className="TraceProfile"
  1527. style={{left: left * 100 + '%'}}
  1528. >
  1529. <Profile />
  1530. </div>
  1531. );
  1532. })}
  1533. </Fragment>
  1534. );
  1535. }
  1536. interface AutogroupedTraceBarProps {
  1537. color: string;
  1538. entire_space: [number, number] | null;
  1539. errors: TraceTreeNode<TraceTree.Transaction>['errors'];
  1540. manager: VirtualizedViewManager;
  1541. node_spaces: [number, number][];
  1542. performance_issues: TraceTreeNode<TraceTree.Transaction>['performance_issues'];
  1543. profiles: TraceTreeNode<TraceTree.NodeValue>['profiles'];
  1544. virtualized_index: number;
  1545. }
  1546. function AutogroupedTraceBar(props: AutogroupedTraceBarProps) {
  1547. if (props.node_spaces && props.node_spaces.length <= 1) {
  1548. return (
  1549. <TraceBar
  1550. color={props.color}
  1551. node_space={props.entire_space}
  1552. manager={props.manager}
  1553. virtualized_index={props.virtualized_index}
  1554. errors={props.errors}
  1555. performance_issues={props.performance_issues}
  1556. profiles={props.profiles}
  1557. />
  1558. );
  1559. }
  1560. if (!props.node_spaces || !props.entire_space) {
  1561. return null;
  1562. }
  1563. const duration = getDuration(props.entire_space[1] / 1000, 2, true);
  1564. const spanTransform = props.manager.computeSpanCSSMatrixTransform(props.entire_space);
  1565. const [inside, textTransform] = props.manager.computeSpanTextPlacement(
  1566. props.entire_space,
  1567. duration
  1568. );
  1569. return (
  1570. <Fragment>
  1571. <div
  1572. ref={r =>
  1573. props.manager.registerSpanBarRef(
  1574. r,
  1575. props.entire_space!,
  1576. props.virtualized_index
  1577. )
  1578. }
  1579. className="TraceBar Invisible"
  1580. style={{
  1581. transform: `matrix(${spanTransform.join(',')})`,
  1582. backgroundColor: props.color,
  1583. }}
  1584. >
  1585. {props.node_spaces.map((node_space, i) => {
  1586. const width = node_space[1] / props.entire_space![1];
  1587. const left = props.manager.computeRelativeLeftPositionFromOrigin(
  1588. node_space[0],
  1589. props.entire_space!
  1590. );
  1591. return (
  1592. <div
  1593. key={i}
  1594. className="TraceBar"
  1595. style={{
  1596. left: `${left * 100}%`,
  1597. width: `${width * 100}%`,
  1598. backgroundColor: props.color,
  1599. }}
  1600. />
  1601. );
  1602. })}
  1603. {props.profiles.length > 0 ? (
  1604. <Profiles
  1605. node_space={props.entire_space}
  1606. profiles={props.profiles}
  1607. manager={props.manager}
  1608. />
  1609. ) : null}
  1610. {props.errors.size > 0 ? (
  1611. <Errors
  1612. node_space={props.entire_space}
  1613. errors={props.errors}
  1614. manager={props.manager}
  1615. />
  1616. ) : null}
  1617. {props.performance_issues.size > 0 ? (
  1618. <PerformanceIssues
  1619. node_space={props.entire_space}
  1620. performance_issues={props.performance_issues}
  1621. manager={props.manager}
  1622. />
  1623. ) : null}
  1624. </div>
  1625. <div
  1626. ref={r =>
  1627. props.manager.registerSpanBarTextRef(
  1628. r,
  1629. duration,
  1630. props.entire_space!,
  1631. props.virtualized_index
  1632. )
  1633. }
  1634. className="TraceBarDuration"
  1635. style={{
  1636. color: inside ? 'white' : '',
  1637. transform: `translate(${textTransform ?? 0}px, 0)`,
  1638. }}
  1639. >
  1640. {duration}
  1641. </div>
  1642. </Fragment>
  1643. );
  1644. }
  1645. /**
  1646. * This is a wrapper around the Trace component to apply styles
  1647. * to the trace tree. It exists because we _do not_ want to trigger
  1648. * emotion's css parsing logic as it is very slow and will cause
  1649. * the scrolling to flicker.
  1650. */
  1651. const TraceStylingWrapper = styled('div')`
  1652. margin: auto;
  1653. overscroll-behavior: none;
  1654. box-shadow: 0 0 0 1px ${p => p.theme.border};
  1655. position: absolute;
  1656. left: 0;
  1657. top: 0;
  1658. width: 100%;
  1659. height: 100%;
  1660. grid-area: trace;
  1661. padding-top: 26px;
  1662. &.WithIndicators {
  1663. padding-top: 44px;
  1664. &:before {
  1665. height: 44px;
  1666. }
  1667. .TraceIndicator.Timeline {
  1668. .TraceIndicatorLabel {
  1669. top: 26px;
  1670. }
  1671. .TraceIndicatorLine {
  1672. top: 30px;
  1673. }
  1674. }
  1675. }
  1676. &:before {
  1677. content: '';
  1678. position: absolute;
  1679. left: 0;
  1680. top: 0;
  1681. width: 100%;
  1682. height: 26px;
  1683. background-color: ${p => p.theme.backgroundSecondary};
  1684. border-bottom: 1px solid ${p => p.theme.border};
  1685. }
  1686. &.Loading {
  1687. .TraceRow {
  1688. .TraceLeftColumnInner {
  1689. width: 100%;
  1690. }
  1691. }
  1692. .TraceRightColumn {
  1693. background-color: transparent !important;
  1694. }
  1695. .TraceDivider {
  1696. pointer-events: none;
  1697. }
  1698. }
  1699. .TraceDivider {
  1700. position: absolute;
  1701. height: 100%;
  1702. background-color: transparent;
  1703. top: 0;
  1704. cursor: col-resize;
  1705. z-index: 10;
  1706. &:before {
  1707. content: '';
  1708. position: absolute;
  1709. width: 1px;
  1710. height: 100%;
  1711. background-color: ${p => p.theme.border};
  1712. left: 50%;
  1713. }
  1714. &:hover {
  1715. &:before {
  1716. background-color: ${p => p.theme.purple300};
  1717. }
  1718. }
  1719. }
  1720. .TraceIndicatorContainer {
  1721. overflow: hidden;
  1722. width: 100%;
  1723. height: 100%;
  1724. position: absolute;
  1725. right: 0;
  1726. top: 0;
  1727. }
  1728. .TraceIndicator {
  1729. z-index: 1;
  1730. width: 3px;
  1731. height: 100%;
  1732. top: 0;
  1733. position: absolute;
  1734. .TraceIndicatorLabel {
  1735. min-width: 34px;
  1736. text-align: center;
  1737. position: absolute;
  1738. font-size: 10px;
  1739. font-weight: bold;
  1740. color: ${p => p.theme.textColor};
  1741. background-color: ${p => p.theme.background};
  1742. border-radius: ${p => p.theme.borderRadius};
  1743. border: 1px solid ${p => p.theme.border};
  1744. padding: 2px;
  1745. display: inline-block;
  1746. line-height: 1;
  1747. margin-top: 2px;
  1748. white-space: nowrap;
  1749. }
  1750. .TraceIndicatorLine {
  1751. width: 1px;
  1752. height: 100%;
  1753. top: 20px;
  1754. position: absolute;
  1755. left: 50%;
  1756. transform: translateX(-2px);
  1757. background: repeating-linear-gradient(
  1758. to bottom,
  1759. transparent 0 4px,
  1760. ${p => p.theme.textColor} 4px 8px
  1761. )
  1762. 80%/2px 100% no-repeat;
  1763. }
  1764. &.Errored {
  1765. .TraceIndicatorLabel {
  1766. border: 1px solid ${p => p.theme.error};
  1767. color: ${p => p.theme.error};
  1768. }
  1769. .TraceIndicatorLine {
  1770. background: repeating-linear-gradient(
  1771. to bottom,
  1772. transparent 0 4px,
  1773. ${p => p.theme.error} 4px 8px
  1774. )
  1775. 80%/2px 100% no-repeat;
  1776. }
  1777. }
  1778. &.Timeline {
  1779. opacity: 1;
  1780. z-index: 1;
  1781. pointer-events: none;
  1782. .TraceIndicatorLabel {
  1783. font-weight: normal;
  1784. min-width: 0;
  1785. top: 8px;
  1786. width: auto;
  1787. border: none;
  1788. background-color: transparent;
  1789. color: ${p => p.theme.subText};
  1790. }
  1791. .TraceIndicatorLine {
  1792. background: ${p => p.theme.translucentGray100};
  1793. top: 8px;
  1794. }
  1795. }
  1796. }
  1797. .TraceRow {
  1798. display: flex;
  1799. align-items: center;
  1800. position: absolute;
  1801. height: 24px;
  1802. width: 100%;
  1803. transition: none;
  1804. font-size: ${p => p.theme.fontSizeSmall};
  1805. .TraceError {
  1806. position: absolute;
  1807. top: 50%;
  1808. transform: translate(-50%, -50%) scaleX(var(--inverse-span-scale));
  1809. background: ${p => p.theme.background};
  1810. width: 18px !important;
  1811. height: 18px !important;
  1812. background-color: ${p => p.theme.error};
  1813. border-radius: 50%;
  1814. display: flex;
  1815. align-items: center;
  1816. justify-content: center;
  1817. svg {
  1818. fill: ${p => p.theme.white};
  1819. }
  1820. }
  1821. .TraceProfile {
  1822. position: absolute;
  1823. top: 50%;
  1824. transform: translate(-50%, -50%) scaleX(var(--inverse-span-scale));
  1825. background: ${p => p.theme.background};
  1826. width: 18px !important;
  1827. height: 18px !important;
  1828. background-color: ${p => p.theme.purple300};
  1829. border-radius: 50%;
  1830. display: flex;
  1831. align-items: center;
  1832. justify-content: center;
  1833. svg {
  1834. width: 12px;
  1835. height: 12px;
  1836. margin-left: 2px;
  1837. fill: ${p => p.theme.white};
  1838. }
  1839. }
  1840. .TracePerformanceIssue {
  1841. position: absolute;
  1842. top: 0;
  1843. display: flex;
  1844. align-items: center;
  1845. justify-content: flex-start;
  1846. background-color: ${p => p.theme.error};
  1847. height: 16px;
  1848. }
  1849. .TraceRightColumn.Odd {
  1850. background-color: ${p => p.theme.backgroundSecondary};
  1851. }
  1852. &:hover {
  1853. background-color: ${p => p.theme.backgroundSecondary};
  1854. }
  1855. &.Highlight {
  1856. box-shadow: inset 0 0 0 1px ${p => p.theme.blue200} !important;
  1857. .TraceLeftColumn {
  1858. box-shadow: inset 0px 0 0px 1px ${p => p.theme.blue200} !important;
  1859. }
  1860. }
  1861. &.Highlight,
  1862. &:focus {
  1863. outline: none;
  1864. background-color: ${p => p.theme.backgroundTertiary};
  1865. .TraceRightColumn.Odd {
  1866. background-color: transparent !important;
  1867. }
  1868. }
  1869. &:focus,
  1870. &[tabindex='0'] {
  1871. background-color: ${p => p.theme.backgroundTertiary};
  1872. box-shadow: inset 0 0 0 1px ${p => p.theme.blue300} !important;
  1873. .TraceLeftColumn {
  1874. box-shadow: inset 0px 0 0px 1px ${p => p.theme.blue300} !important;
  1875. }
  1876. .TraceRightColumn.Odd {
  1877. background-color: transparent !important;
  1878. }
  1879. }
  1880. &.Errored {
  1881. color: ${p => p.theme.error};
  1882. .TraceChildrenCount {
  1883. border: 2px solid ${p => p.theme.error};
  1884. svg {
  1885. fill: ${p => p.theme.error};
  1886. }
  1887. }
  1888. &:focus,
  1889. &[tabindex='0'] {
  1890. box-shadow: inset 0 0 0 1px ${p => p.theme.red300} !important;
  1891. .TraceLeftColumn {
  1892. box-shadow: inset 0px 0 0px 1px ${p => p.theme.red300} !important;
  1893. }
  1894. }
  1895. }
  1896. &.SearchResult {
  1897. background-color: ${p => p.theme.yellow100};
  1898. .TraceRightColumn {
  1899. background-color: transparent;
  1900. }
  1901. }
  1902. &.Autogrouped {
  1903. color: ${p => p.theme.blue300};
  1904. &.Errored {
  1905. .TraceChildrenCount {
  1906. background-color: ${p => p.theme.error} !important;
  1907. }
  1908. }
  1909. .TraceDescription {
  1910. font-weight: bold;
  1911. }
  1912. .TraceChildrenCountWrapper {
  1913. button {
  1914. color: ${p => p.theme.white};
  1915. background-color: ${p => p.theme.blue300};
  1916. }
  1917. svg {
  1918. fill: ${p => p.theme.white};
  1919. }
  1920. }
  1921. }
  1922. }
  1923. .TraceLeftColumn {
  1924. height: 100%;
  1925. white-space: nowrap;
  1926. display: flex;
  1927. align-items: center;
  1928. overflow: hidden;
  1929. will-change: width;
  1930. box-shadow: inset 1px 0 0px 0px transparent;
  1931. .TraceLeftColumnInner {
  1932. height: 100%;
  1933. white-space: nowrap;
  1934. display: flex;
  1935. align-items: center;
  1936. will-change: transform;
  1937. transform-origin: left center;
  1938. img {
  1939. width: 16px;
  1940. height: 16px;
  1941. }
  1942. }
  1943. }
  1944. .TraceRightColumn {
  1945. height: 100%;
  1946. overflow: hidden;
  1947. position: relative;
  1948. display: flex;
  1949. align-items: center;
  1950. will-change: width;
  1951. z-index: 1;
  1952. cursor: pointer;
  1953. &:hover {
  1954. .TraceArrow.Visible {
  1955. opacity: 1;
  1956. transition: 300ms 300ms ease-out;
  1957. pointer-events: auto;
  1958. }
  1959. }
  1960. }
  1961. .TraceBar {
  1962. position: absolute;
  1963. height: 16px;
  1964. width: 100%;
  1965. background-color: black;
  1966. transform-origin: left center;
  1967. &.Invisible {
  1968. background-color: transparent !important;
  1969. > div {
  1970. height: 100%;
  1971. }
  1972. .TraceError {
  1973. top: -1px;
  1974. transform: translate(-50%, 0);
  1975. }
  1976. }
  1977. svg {
  1978. width: 14px;
  1979. height: 14px;
  1980. }
  1981. }
  1982. .TraceArrow {
  1983. position: absolute;
  1984. pointer-events: none;
  1985. top: 0;
  1986. width: 14px;
  1987. height: 24px;
  1988. opacity: 0;
  1989. background-color: transparent;
  1990. border: none;
  1991. transition: 60ms ease-out;
  1992. font-size: ${p => p.theme.fontSizeMedium};
  1993. color: ${p => p.theme.subText};
  1994. padding: 0 2px;
  1995. display: flex;
  1996. align-items: center;
  1997. svg {
  1998. fill: ${p => p.theme.subText};
  1999. }
  2000. &.Left {
  2001. left: 0;
  2002. }
  2003. &.Right {
  2004. right: 0;
  2005. transform: rotate(180deg);
  2006. }
  2007. }
  2008. .TraceBarDuration {
  2009. display: inline-block;
  2010. transform-origin: left center;
  2011. font-size: ${p => p.theme.fontSizeExtraSmall};
  2012. color: ${p => p.theme.gray300};
  2013. white-space: nowrap;
  2014. font-variant-numeric: tabular-nums;
  2015. position: absolute;
  2016. transition: color 0.1s ease-in-out;
  2017. }
  2018. .TraceChildrenCount {
  2019. height: 16px;
  2020. white-space: nowrap;
  2021. min-width: 30px;
  2022. display: flex;
  2023. align-items: center;
  2024. justify-content: center;
  2025. border-radius: 99px;
  2026. padding: 0px 4px;
  2027. transition: all 0.15s ease-in-out;
  2028. background: ${p => p.theme.background};
  2029. border: 2px solid ${p => p.theme.border};
  2030. line-height: 0;
  2031. z-index: 1;
  2032. font-size: 10px;
  2033. box-shadow: ${p => p.theme.dropShadowLight};
  2034. margin-right: 8px;
  2035. .TraceChildrenCountContent {
  2036. + .TraceChildrenCountAction {
  2037. margin-left: 2px;
  2038. }
  2039. }
  2040. .TraceChildrenCountAction {
  2041. position: relative;
  2042. display: flex;
  2043. align-items: center;
  2044. justify-content: center;
  2045. }
  2046. .TraceActionsLoadingIndicator {
  2047. margin: 0;
  2048. position: absolute;
  2049. top: 50%;
  2050. left: 50%;
  2051. transform: translate(-50%, -50%);
  2052. background-color: ${p => p.theme.background};
  2053. animation: show 0.1s ease-in-out forwards;
  2054. @keyframes show {
  2055. from {
  2056. opacity: 0;
  2057. transform: translate(-50%, -50%) scale(0.86);
  2058. }
  2059. to {
  2060. opacity: 1;
  2061. transform: translate(-50%, -50%) scale(1);
  2062. }
  2063. }
  2064. .loading-indicator {
  2065. border-width: 2px;
  2066. }
  2067. .loading-message {
  2068. display: none;
  2069. }
  2070. }
  2071. svg {
  2072. width: 7px;
  2073. transition: none;
  2074. fill: ${p => p.theme.textColor};
  2075. }
  2076. }
  2077. .TraceChildrenCountWrapper {
  2078. display: flex;
  2079. justify-content: flex-end;
  2080. align-items: center;
  2081. min-width: 44px;
  2082. height: 100%;
  2083. position: relative;
  2084. button {
  2085. transition: none;
  2086. }
  2087. &.Orphaned {
  2088. .TraceVerticalConnector,
  2089. .TraceVerticalLastChildConnector,
  2090. .TraceExpandedVerticalConnector {
  2091. border-left: 2px dashed ${p => p.theme.border};
  2092. }
  2093. &::before {
  2094. border-bottom: 2px dashed ${p => p.theme.border};
  2095. }
  2096. }
  2097. &.Root {
  2098. &:before,
  2099. .TraceVerticalLastChildConnector {
  2100. visibility: hidden;
  2101. }
  2102. }
  2103. &::before {
  2104. content: '';
  2105. display: block;
  2106. width: 50%;
  2107. height: 2px;
  2108. border-bottom: 2px solid ${p => p.theme.border};
  2109. position: absolute;
  2110. left: 0;
  2111. top: 50%;
  2112. transform: translateY(-50%);
  2113. }
  2114. &::after {
  2115. content: '';
  2116. background-color: ${p => p.theme.border};
  2117. border-radius: 50%;
  2118. height: 6px;
  2119. width: 6px;
  2120. position: absolute;
  2121. left: 50%;
  2122. top: 50%;
  2123. transform: translateY(-50%);
  2124. }
  2125. }
  2126. .TraceVerticalConnector {
  2127. position: absolute;
  2128. left: 0;
  2129. top: 0;
  2130. bottom: 0;
  2131. height: 100%;
  2132. width: 2px;
  2133. border-left: 2px solid ${p => p.theme.border};
  2134. &.Orphaned {
  2135. border-left: 2px dashed ${p => p.theme.border};
  2136. }
  2137. }
  2138. .TraceVerticalLastChildConnector {
  2139. position: absolute;
  2140. left: 0;
  2141. top: 0;
  2142. bottom: 0;
  2143. height: 50%;
  2144. width: 2px;
  2145. border-left: 2px solid ${p => p.theme.border};
  2146. border-bottom-left-radius: 4px;
  2147. }
  2148. .TraceExpandedVerticalConnector {
  2149. position: absolute;
  2150. bottom: 0;
  2151. height: 50%;
  2152. left: 50%;
  2153. width: 2px;
  2154. border-left: 2px solid ${p => p.theme.border};
  2155. }
  2156. .TraceOperation {
  2157. margin-left: 4px;
  2158. text-overflow: ellipsis;
  2159. white-space: nowrap;
  2160. font-weight: bold;
  2161. }
  2162. .TraceEmDash {
  2163. margin-left: 4px;
  2164. margin-right: 4px;
  2165. }
  2166. .TraceDescription {
  2167. white-space: nowrap;
  2168. }
  2169. `;