widgetDefinitions.tsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. import {CHART_PALETTE} from 'sentry/constants/chartPalette';
  2. import {t} from 'sentry/locale';
  3. import type {Organization} from 'sentry/types/organization';
  4. import {SPAN_OP_BREAKDOWN_FIELDS} from 'sentry/utils/discover/fields';
  5. import {getTermHelp, PerformanceTerm} from '../../data';
  6. import {GenericPerformanceWidgetDataType} from './types';
  7. export interface ChartDefinition {
  8. dataType: GenericPerformanceWidgetDataType;
  9. fields: string[];
  10. // Additional fields to get requested but are not directly used in visualization.
  11. title: string;
  12. titleTooltip: string;
  13. // The first field in the list will be treated as the primary field in most widgets (except for special casing).
  14. allowsOpenInDiscover?: boolean;
  15. chartColor?: string;
  16. secondaryFields?: string[]; // Optional. Will default to colors depending on placement in list or colors from the chart itself.
  17. vitalStops?: {
  18. meh: number;
  19. poor: number;
  20. };
  21. }
  22. export enum PerformanceWidgetSetting {
  23. DURATION_HISTOGRAM = 'duration_histogram',
  24. LCP_HISTOGRAM = 'lcp_histogram',
  25. FCP_HISTOGRAM = 'fcp_histogram',
  26. FID_HISTOGRAM = 'fid_histogram',
  27. APDEX_AREA = 'apdex_area',
  28. P50_DURATION_AREA = 'p50_duration_area',
  29. P75_DURATION_AREA = 'p75_duration_area',
  30. P95_DURATION_AREA = 'p95_duration_area',
  31. P99_DURATION_AREA = 'p99_duration_area',
  32. P75_LCP_AREA = 'p75_lcp_area',
  33. TPM_AREA = 'tpm_area',
  34. FAILURE_RATE_AREA = 'failure_rate_area',
  35. USER_MISERY_AREA = 'user_misery_area',
  36. WORST_LCP_VITALS = 'worst_lcp_vitals',
  37. WORST_FCP_VITALS = 'worst_fcp_vitals',
  38. WORST_CLS_VITALS = 'worst_cls_vitals',
  39. WORST_FID_VITALS = 'worst_fid_vitals',
  40. MOST_CHANGED = 'most_changed',
  41. MOST_IMPROVED = 'most_improved',
  42. MOST_REGRESSED = 'most_regressed',
  43. MOST_RELATED_ERRORS = 'most_related_errors',
  44. MOST_RELATED_ISSUES = 'most_related_issues',
  45. MOST_TIME_SPENT_DB_QUERIES = 'most_time_spent_db_queries',
  46. HIGHEST_OPPORTUNITY_PAGES = 'highest_opportunity_pages',
  47. SLOW_HTTP_OPS = 'slow_http_ops',
  48. SLOW_DB_OPS = 'slow_db_ops',
  49. SLOW_RESOURCE_OPS = 'slow_resource_ops',
  50. SLOW_BROWSER_OPS = 'slow_browser_ops',
  51. COLD_STARTUP_AREA = 'cold_startup_area',
  52. WARM_STARTUP_AREA = 'warm_startup_area',
  53. SLOW_FRAMES_AREA = 'slow_frames_area',
  54. FROZEN_FRAMES_AREA = 'frozen_frames_area',
  55. MOST_SLOW_FRAMES = 'most_slow_frames',
  56. MOST_FROZEN_FRAMES = 'most_frozen_frames',
  57. SPAN_OPERATIONS = 'span_operations',
  58. TIME_TO_INITIAL_DISPLAY = 'time_to_initial_display',
  59. TIME_TO_FULL_DISPLAY = 'time_to_full_display',
  60. OVERALL_PERFORMANCE_SCORE = 'overall_performance_score',
  61. MOST_TIME_CONSUMING_RESOURCES = 'most_time_consuming_resources',
  62. SLOW_SCREENS_BY_TTID = 'slow_screens_by_ttid',
  63. SLOW_SCREENS_BY_COLD_START = 'slow_screens_by_cold_start',
  64. SLOW_SCREENS_BY_WARM_START = 'slow_screens_by_warm_start',
  65. }
  66. const WIDGET_PALETTE = CHART_PALETTE[5];
  67. export const WIDGET_DEFINITIONS: ({
  68. organization,
  69. }: {
  70. organization: Organization;
  71. }) => Record<PerformanceWidgetSetting, ChartDefinition> = ({
  72. organization,
  73. }: {
  74. organization: Organization;
  75. }) => ({
  76. [PerformanceWidgetSetting.DURATION_HISTOGRAM]: {
  77. title: t('Duration Distribution'),
  78. titleTooltip: getTermHelp(organization, PerformanceTerm.DURATION_DISTRIBUTION),
  79. fields: ['transaction.duration'],
  80. dataType: GenericPerformanceWidgetDataType.HISTOGRAM,
  81. chartColor: WIDGET_PALETTE[5],
  82. },
  83. [PerformanceWidgetSetting.LCP_HISTOGRAM]: {
  84. title: t('LCP Distribution'),
  85. titleTooltip: getTermHelp(organization, PerformanceTerm.DURATION_DISTRIBUTION),
  86. fields: ['measurements.lcp'],
  87. dataType: GenericPerformanceWidgetDataType.HISTOGRAM,
  88. chartColor: WIDGET_PALETTE[5],
  89. },
  90. [PerformanceWidgetSetting.FCP_HISTOGRAM]: {
  91. title: t('FCP Distribution'),
  92. titleTooltip: getTermHelp(organization, PerformanceTerm.DURATION_DISTRIBUTION),
  93. fields: ['measurements.fcp'],
  94. dataType: GenericPerformanceWidgetDataType.HISTOGRAM,
  95. chartColor: WIDGET_PALETTE[5],
  96. },
  97. [PerformanceWidgetSetting.FID_HISTOGRAM]: {
  98. title: t('FID Distribution'),
  99. titleTooltip: getTermHelp(organization, PerformanceTerm.DURATION_DISTRIBUTION),
  100. fields: ['measurements.fid'],
  101. dataType: GenericPerformanceWidgetDataType.HISTOGRAM,
  102. chartColor: WIDGET_PALETTE[5],
  103. },
  104. [PerformanceWidgetSetting.WORST_LCP_VITALS]: {
  105. title: t('Worst LCP Web Vitals'),
  106. titleTooltip: getTermHelp(organization, PerformanceTerm.LCP),
  107. fields: ['measurements.lcp'],
  108. vitalStops: {
  109. poor: 4000,
  110. meh: 2500,
  111. },
  112. dataType: GenericPerformanceWidgetDataType.VITALS,
  113. },
  114. [PerformanceWidgetSetting.WORST_FCP_VITALS]: {
  115. title: t('Worst FCP Web Vitals'),
  116. titleTooltip: getTermHelp(organization, PerformanceTerm.FCP),
  117. fields: ['measurements.fcp'],
  118. vitalStops: {
  119. poor: 3000,
  120. meh: 1000,
  121. },
  122. dataType: GenericPerformanceWidgetDataType.VITALS,
  123. },
  124. [PerformanceWidgetSetting.WORST_FID_VITALS]: {
  125. title: t('Worst FID Web Vitals'),
  126. titleTooltip: getTermHelp(organization, PerformanceTerm.FID),
  127. fields: ['measurements.fid'],
  128. vitalStops: {
  129. poor: 300,
  130. meh: 100,
  131. },
  132. dataType: GenericPerformanceWidgetDataType.VITALS,
  133. },
  134. [PerformanceWidgetSetting.WORST_CLS_VITALS]: {
  135. title: t('Worst CLS Web Vitals'),
  136. titleTooltip: getTermHelp(organization, PerformanceTerm.CLS),
  137. fields: ['measurements.cls'],
  138. vitalStops: {
  139. poor: 0.25,
  140. meh: 0.1,
  141. },
  142. dataType: GenericPerformanceWidgetDataType.VITALS,
  143. },
  144. [PerformanceWidgetSetting.TPM_AREA]: {
  145. title: t('Transactions Per Minute'),
  146. titleTooltip: getTermHelp(organization, PerformanceTerm.TPM),
  147. fields: ['tpm()'],
  148. dataType: GenericPerformanceWidgetDataType.AREA,
  149. chartColor: WIDGET_PALETTE[1],
  150. allowsOpenInDiscover: true,
  151. },
  152. [PerformanceWidgetSetting.APDEX_AREA]: {
  153. title: t('Apdex'),
  154. titleTooltip: getTermHelp(organization, PerformanceTerm.APDEX),
  155. fields: ['apdex()'],
  156. dataType: GenericPerformanceWidgetDataType.AREA,
  157. chartColor: WIDGET_PALETTE[4],
  158. allowsOpenInDiscover: true,
  159. },
  160. [PerformanceWidgetSetting.P50_DURATION_AREA]: {
  161. title: t('p50 Duration'),
  162. titleTooltip: getTermHelp(organization, PerformanceTerm.P50),
  163. fields: ['p50(transaction.duration)'],
  164. dataType: GenericPerformanceWidgetDataType.AREA,
  165. chartColor: WIDGET_PALETTE[3],
  166. allowsOpenInDiscover: true,
  167. },
  168. [PerformanceWidgetSetting.P75_DURATION_AREA]: {
  169. title: t('p75 Duration'),
  170. titleTooltip: getTermHelp(organization, PerformanceTerm.P75),
  171. fields: ['p75(transaction.duration)'],
  172. dataType: GenericPerformanceWidgetDataType.AREA,
  173. chartColor: WIDGET_PALETTE[3],
  174. allowsOpenInDiscover: true,
  175. },
  176. [PerformanceWidgetSetting.P95_DURATION_AREA]: {
  177. title: t('p95 Duration'),
  178. titleTooltip: getTermHelp(organization, PerformanceTerm.P95),
  179. fields: ['p95(transaction.duration)'],
  180. dataType: GenericPerformanceWidgetDataType.AREA,
  181. chartColor: WIDGET_PALETTE[3],
  182. allowsOpenInDiscover: true,
  183. },
  184. [PerformanceWidgetSetting.P99_DURATION_AREA]: {
  185. title: t('p99 Duration'),
  186. titleTooltip: getTermHelp(organization, PerformanceTerm.P99),
  187. fields: ['p99(transaction.duration)'],
  188. dataType: GenericPerformanceWidgetDataType.AREA,
  189. chartColor: WIDGET_PALETTE[3],
  190. allowsOpenInDiscover: true,
  191. },
  192. [PerformanceWidgetSetting.P75_LCP_AREA]: {
  193. title: t('p75 LCP'),
  194. titleTooltip: getTermHelp(organization, PerformanceTerm.P75),
  195. fields: ['p75(measurements.lcp)'],
  196. dataType: GenericPerformanceWidgetDataType.AREA,
  197. chartColor: WIDGET_PALETTE[1],
  198. allowsOpenInDiscover: true,
  199. },
  200. [PerformanceWidgetSetting.FAILURE_RATE_AREA]: {
  201. title: t('Failure Rate'),
  202. titleTooltip: getTermHelp(organization, PerformanceTerm.FAILURE_RATE),
  203. fields: ['failure_rate()'],
  204. dataType: GenericPerformanceWidgetDataType.AREA,
  205. chartColor: WIDGET_PALETTE[2],
  206. allowsOpenInDiscover: true,
  207. },
  208. [PerformanceWidgetSetting.USER_MISERY_AREA]: {
  209. title: t('User Misery'),
  210. titleTooltip: getTermHelp(organization, PerformanceTerm.USER_MISERY),
  211. fields: [`user_misery()`],
  212. dataType: GenericPerformanceWidgetDataType.AREA,
  213. chartColor: WIDGET_PALETTE[0],
  214. allowsOpenInDiscover: true,
  215. },
  216. [PerformanceWidgetSetting.COLD_STARTUP_AREA]: {
  217. title: t('Cold Startup Time'),
  218. titleTooltip: getTermHelp(organization, PerformanceTerm.APP_START_COLD),
  219. fields: ['p75(measurements.app_start_cold)'],
  220. dataType: GenericPerformanceWidgetDataType.AREA,
  221. chartColor: WIDGET_PALETTE[4],
  222. allowsOpenInDiscover: true,
  223. },
  224. [PerformanceWidgetSetting.WARM_STARTUP_AREA]: {
  225. title: t('Warm Startup Time'),
  226. titleTooltip: getTermHelp(organization, PerformanceTerm.APP_START_WARM),
  227. fields: ['p75(measurements.app_start_warm)'],
  228. dataType: GenericPerformanceWidgetDataType.AREA,
  229. chartColor: WIDGET_PALETTE[3],
  230. allowsOpenInDiscover: true,
  231. },
  232. [PerformanceWidgetSetting.SLOW_FRAMES_AREA]: {
  233. title: t('Slow Frames'),
  234. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_FRAMES),
  235. fields: ['p75(measurements.frames_slow_rate)'],
  236. dataType: GenericPerformanceWidgetDataType.AREA,
  237. chartColor: WIDGET_PALETTE[0],
  238. allowsOpenInDiscover: true,
  239. },
  240. [PerformanceWidgetSetting.FROZEN_FRAMES_AREA]: {
  241. title: t('Frozen Frames'),
  242. titleTooltip: getTermHelp(organization, PerformanceTerm.FROZEN_FRAMES),
  243. fields: ['p75(measurements.frames_frozen_rate)'],
  244. dataType: GenericPerformanceWidgetDataType.AREA,
  245. chartColor: WIDGET_PALETTE[5],
  246. allowsOpenInDiscover: true,
  247. },
  248. [PerformanceWidgetSetting.MOST_RELATED_ERRORS]: {
  249. title: t('Most Related Errors'),
  250. titleTooltip: getTermHelp(organization, PerformanceTerm.MOST_ERRORS),
  251. fields: [`failure_count()`],
  252. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  253. chartColor: WIDGET_PALETTE[0],
  254. },
  255. [PerformanceWidgetSetting.MOST_RELATED_ISSUES]: {
  256. title: t('Most Related Issues'),
  257. titleTooltip: getTermHelp(organization, PerformanceTerm.MOST_ISSUES),
  258. fields: [`count()`],
  259. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  260. chartColor: WIDGET_PALETTE[0],
  261. },
  262. [PerformanceWidgetSetting.MOST_TIME_SPENT_DB_QUERIES]: {
  263. title: t('Most Time-Consuming Queries'),
  264. subTitle: t('Top queries by total duration'),
  265. titleTooltip: getTermHelp(organization, PerformanceTerm.MOST_TIME_SPENT_DB_QUERIES),
  266. fields: [`time_spent_percentage()`],
  267. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  268. chartColor: WIDGET_PALETTE[0],
  269. },
  270. [PerformanceWidgetSetting.MOST_TIME_CONSUMING_RESOURCES]: {
  271. title: t('Most Time Consuming Resources'),
  272. subTitle: t('Render blocking for pages'),
  273. titleTooltip: getTermHelp(
  274. organization,
  275. PerformanceTerm.MOST_TIME_CONSUMING_RESOURCES
  276. ),
  277. fields: [`time_spent_percentage()`],
  278. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  279. chartColor: WIDGET_PALETTE[0],
  280. },
  281. [PerformanceWidgetSetting.HIGHEST_OPPORTUNITY_PAGES]: {
  282. title: t('Best Page Opportunities'),
  283. subTitle: t('Pages to improve your performance score'),
  284. titleTooltip: '',
  285. fields: [`count()`],
  286. dataType: GenericPerformanceWidgetDataType.PERFORMANCE_SCORE_LIST,
  287. },
  288. [PerformanceWidgetSetting.OVERALL_PERFORMANCE_SCORE]: {
  289. title: t('Performance Score'),
  290. subTitle: t('The overall performance score across selected frontend projects only'),
  291. titleTooltip: '',
  292. fields: [],
  293. dataType: GenericPerformanceWidgetDataType.PERFORMANCE_SCORE,
  294. },
  295. [PerformanceWidgetSetting.SLOW_HTTP_OPS]: {
  296. title: t('Slow HTTP Ops'),
  297. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_HTTP_SPANS),
  298. fields: [`p75(spans.http)`, 'p75(spans.db)'],
  299. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  300. chartColor: WIDGET_PALETTE[0],
  301. },
  302. [PerformanceWidgetSetting.SLOW_BROWSER_OPS]: {
  303. title: t('Slow Browser Ops'),
  304. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_HTTP_SPANS),
  305. fields: [`p75(spans.browser)`],
  306. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  307. chartColor: WIDGET_PALETTE[0],
  308. },
  309. [PerformanceWidgetSetting.SLOW_RESOURCE_OPS]: {
  310. title: t('Slow Resource Ops'),
  311. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_HTTP_SPANS),
  312. fields: [`p75(spans.resource)`],
  313. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  314. chartColor: WIDGET_PALETTE[0],
  315. },
  316. [PerformanceWidgetSetting.SLOW_DB_OPS]: {
  317. title: t('Slow DB Ops'),
  318. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_HTTP_SPANS),
  319. fields: [`p75(spans.db)`, 'p75(spans.http)'],
  320. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  321. chartColor: WIDGET_PALETTE[0],
  322. },
  323. [PerformanceWidgetSetting.TIME_TO_INITIAL_DISPLAY]: {
  324. title: t('Time to Initial Display'),
  325. titleTooltip: getTermHelp(organization, PerformanceTerm.TIME_TO_INITIAL_DISPLAY),
  326. fields: ['p75(measurements.time_to_initial_display)'],
  327. dataType: GenericPerformanceWidgetDataType.AREA,
  328. chartColor: WIDGET_PALETTE[4],
  329. allowsOpenInDiscover: true,
  330. },
  331. [PerformanceWidgetSetting.TIME_TO_FULL_DISPLAY]: {
  332. title: t('Time to Full Display'),
  333. titleTooltip: getTermHelp(organization, PerformanceTerm.TIME_TO_FULL_DISPLAY),
  334. fields: ['p75(measurements.time_to_full_display)'],
  335. dataType: GenericPerformanceWidgetDataType.AREA,
  336. chartColor: WIDGET_PALETTE[4],
  337. allowsOpenInDiscover: true,
  338. },
  339. [PerformanceWidgetSetting.MOST_SLOW_FRAMES]: {
  340. title: t('Most Slow Frames'),
  341. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_FRAMES),
  342. fields: ['avg(measurements.frames_slow)'],
  343. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  344. chartColor: WIDGET_PALETTE[0],
  345. },
  346. [PerformanceWidgetSetting.MOST_FROZEN_FRAMES]: {
  347. title: t('Most Frozen Frames'),
  348. titleTooltip: getTermHelp(organization, PerformanceTerm.FROZEN_FRAMES),
  349. fields: ['avg(measurements.frames_frozen)'],
  350. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  351. chartColor: WIDGET_PALETTE[0],
  352. },
  353. [PerformanceWidgetSetting.MOST_IMPROVED]: {
  354. title: t('Most Improved (P95)'),
  355. titleTooltip: t(
  356. 'This compares the baseline (%s) of the past with the present.',
  357. 'improved'
  358. ),
  359. fields: [],
  360. dataType: GenericPerformanceWidgetDataType.TRENDS,
  361. },
  362. [PerformanceWidgetSetting.MOST_REGRESSED]: {
  363. title: t('Most Regressed (P95)'),
  364. titleTooltip: t(
  365. 'This compares the baseline (%s) of the past with the present.',
  366. 'regressed'
  367. ),
  368. fields: [],
  369. dataType: GenericPerformanceWidgetDataType.TRENDS,
  370. },
  371. [PerformanceWidgetSetting.MOST_CHANGED]: {
  372. title: t('Most Changed (P95)'),
  373. titleTooltip: t(
  374. 'This compares the baseline (%s) of the past with the present.',
  375. 'changed'
  376. ),
  377. fields: [],
  378. dataType: GenericPerformanceWidgetDataType.TRENDS,
  379. },
  380. [PerformanceWidgetSetting.SPAN_OPERATIONS]: {
  381. title: t('Span Operations Breakdown'),
  382. titleTooltip: '',
  383. fields: SPAN_OP_BREAKDOWN_FIELDS.map(spanOp => `p75(${spanOp})`),
  384. dataType: GenericPerformanceWidgetDataType.STACKED_AREA,
  385. },
  386. [PerformanceWidgetSetting.SLOW_SCREENS_BY_TTID]: {
  387. title: t('Average TTIDs'),
  388. titleTooltip: '',
  389. subTitle: t('Top screens by count'),
  390. fields: ['avg(measurements.time_to_initial_display)'],
  391. dataType: GenericPerformanceWidgetDataType.SLOW_SCREENS_BY_TTID,
  392. },
  393. [PerformanceWidgetSetting.SLOW_SCREENS_BY_COLD_START]: {
  394. title: t('Average Cold Start'),
  395. titleTooltip: '',
  396. subTitle: t('Top screens by start count'),
  397. fields: ['avg(measurements.app_start_cold)'],
  398. dataType: GenericPerformanceWidgetDataType.SLOW_SCREENS_BY_COLD_START,
  399. },
  400. [PerformanceWidgetSetting.SLOW_SCREENS_BY_WARM_START]: {
  401. title: t('Average Warm Start'),
  402. titleTooltip: '',
  403. subTitle: t('Top screens by start count'),
  404. fields: ['avg(measurements.app_start_warm)'],
  405. dataType: GenericPerformanceWidgetDataType.SLOW_SCREENS_BY_WARM_START,
  406. },
  407. });