trace.tsx 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360
  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. cursor: pointer;
  1932. .TraceLeftColumnInner {
  1933. height: 100%;
  1934. white-space: nowrap;
  1935. display: flex;
  1936. align-items: center;
  1937. will-change: transform;
  1938. transform-origin: left center;
  1939. img {
  1940. width: 16px;
  1941. height: 16px;
  1942. }
  1943. }
  1944. }
  1945. .TraceRightColumn {
  1946. height: 100%;
  1947. overflow: hidden;
  1948. position: relative;
  1949. display: flex;
  1950. align-items: center;
  1951. will-change: width;
  1952. z-index: 1;
  1953. cursor: pointer;
  1954. &:hover {
  1955. .TraceArrow.Visible {
  1956. opacity: 1;
  1957. transition: 300ms 300ms ease-out;
  1958. pointer-events: auto;
  1959. }
  1960. }
  1961. }
  1962. .TraceBar {
  1963. position: absolute;
  1964. height: 16px;
  1965. width: 100%;
  1966. background-color: black;
  1967. transform-origin: left center;
  1968. &.Invisible {
  1969. background-color: transparent !important;
  1970. > div {
  1971. height: 100%;
  1972. }
  1973. .TraceError {
  1974. top: -1px;
  1975. transform: translate(-50%, 0);
  1976. }
  1977. }
  1978. svg {
  1979. width: 14px;
  1980. height: 14px;
  1981. }
  1982. }
  1983. .TraceArrow {
  1984. position: absolute;
  1985. pointer-events: none;
  1986. top: 0;
  1987. width: 14px;
  1988. height: 24px;
  1989. opacity: 0;
  1990. background-color: transparent;
  1991. border: none;
  1992. transition: 60ms ease-out;
  1993. font-size: ${p => p.theme.fontSizeMedium};
  1994. color: ${p => p.theme.subText};
  1995. padding: 0 2px;
  1996. display: flex;
  1997. align-items: center;
  1998. svg {
  1999. fill: ${p => p.theme.subText};
  2000. }
  2001. &.Left {
  2002. left: 0;
  2003. }
  2004. &.Right {
  2005. right: 0;
  2006. transform: rotate(180deg);
  2007. }
  2008. }
  2009. .TraceBarDuration {
  2010. display: inline-block;
  2011. transform-origin: left center;
  2012. font-size: ${p => p.theme.fontSizeExtraSmall};
  2013. color: ${p => p.theme.gray300};
  2014. white-space: nowrap;
  2015. font-variant-numeric: tabular-nums;
  2016. position: absolute;
  2017. transition: color 0.1s ease-in-out;
  2018. }
  2019. .TraceChildrenCount {
  2020. height: 16px;
  2021. white-space: nowrap;
  2022. min-width: 30px;
  2023. display: flex;
  2024. align-items: center;
  2025. justify-content: center;
  2026. border-radius: 99px;
  2027. padding: 0px 4px;
  2028. transition: all 0.15s ease-in-out;
  2029. background: ${p => p.theme.background};
  2030. border: 2px solid ${p => p.theme.border};
  2031. line-height: 0;
  2032. z-index: 1;
  2033. font-size: 10px;
  2034. box-shadow: ${p => p.theme.dropShadowLight};
  2035. margin-right: 8px;
  2036. .TraceChildrenCountContent {
  2037. + .TraceChildrenCountAction {
  2038. margin-left: 2px;
  2039. }
  2040. }
  2041. .TraceChildrenCountAction {
  2042. position: relative;
  2043. display: flex;
  2044. align-items: center;
  2045. justify-content: center;
  2046. }
  2047. .TraceActionsLoadingIndicator {
  2048. margin: 0;
  2049. position: absolute;
  2050. top: 50%;
  2051. left: 50%;
  2052. transform: translate(-50%, -50%);
  2053. background-color: ${p => p.theme.background};
  2054. animation: show 0.1s ease-in-out forwards;
  2055. @keyframes show {
  2056. from {
  2057. opacity: 0;
  2058. transform: translate(-50%, -50%) scale(0.86);
  2059. }
  2060. to {
  2061. opacity: 1;
  2062. transform: translate(-50%, -50%) scale(1);
  2063. }
  2064. }
  2065. .loading-indicator {
  2066. border-width: 2px;
  2067. }
  2068. .loading-message {
  2069. display: none;
  2070. }
  2071. }
  2072. svg {
  2073. width: 7px;
  2074. transition: none;
  2075. fill: ${p => p.theme.textColor};
  2076. }
  2077. }
  2078. .TraceChildrenCountWrapper {
  2079. display: flex;
  2080. justify-content: flex-end;
  2081. align-items: center;
  2082. min-width: 44px;
  2083. height: 100%;
  2084. position: relative;
  2085. button {
  2086. transition: none;
  2087. }
  2088. &.Orphaned {
  2089. .TraceVerticalConnector,
  2090. .TraceVerticalLastChildConnector,
  2091. .TraceExpandedVerticalConnector {
  2092. border-left: 2px dashed ${p => p.theme.border};
  2093. }
  2094. &::before {
  2095. border-bottom: 2px dashed ${p => p.theme.border};
  2096. }
  2097. }
  2098. &.Root {
  2099. &:before,
  2100. .TraceVerticalLastChildConnector {
  2101. visibility: hidden;
  2102. }
  2103. }
  2104. &::before {
  2105. content: '';
  2106. display: block;
  2107. width: 50%;
  2108. height: 2px;
  2109. border-bottom: 2px solid ${p => p.theme.border};
  2110. position: absolute;
  2111. left: 0;
  2112. top: 50%;
  2113. transform: translateY(-50%);
  2114. }
  2115. &::after {
  2116. content: '';
  2117. background-color: ${p => p.theme.border};
  2118. border-radius: 50%;
  2119. height: 6px;
  2120. width: 6px;
  2121. position: absolute;
  2122. left: 50%;
  2123. top: 50%;
  2124. transform: translateY(-50%);
  2125. }
  2126. }
  2127. .TraceVerticalConnector {
  2128. position: absolute;
  2129. left: 0;
  2130. top: 0;
  2131. bottom: 0;
  2132. height: 100%;
  2133. width: 2px;
  2134. border-left: 2px solid ${p => p.theme.border};
  2135. &.Orphaned {
  2136. border-left: 2px dashed ${p => p.theme.border};
  2137. }
  2138. }
  2139. .TraceVerticalLastChildConnector {
  2140. position: absolute;
  2141. left: 0;
  2142. top: 0;
  2143. bottom: 0;
  2144. height: 50%;
  2145. width: 2px;
  2146. border-left: 2px solid ${p => p.theme.border};
  2147. border-bottom-left-radius: 4px;
  2148. }
  2149. .TraceExpandedVerticalConnector {
  2150. position: absolute;
  2151. bottom: 0;
  2152. height: 50%;
  2153. left: 50%;
  2154. width: 2px;
  2155. border-left: 2px solid ${p => p.theme.border};
  2156. }
  2157. .TraceOperation {
  2158. margin-left: 4px;
  2159. text-overflow: ellipsis;
  2160. white-space: nowrap;
  2161. font-weight: bold;
  2162. }
  2163. .TraceEmDash {
  2164. margin-left: 4px;
  2165. margin-right: 4px;
  2166. }
  2167. .TraceDescription {
  2168. white-space: nowrap;
  2169. }
  2170. `;