widgetDefinitions.tsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. import {CHART_PALETTE} from 'sentry/constants/chartPalette';
  2. import {t} from 'sentry/locale';
  3. import {Organization} from 'sentry/types';
  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. }
  64. const WIDGET_PALETTE = CHART_PALETTE[5];
  65. export const WIDGET_DEFINITIONS: ({
  66. organization,
  67. }: {
  68. organization: Organization;
  69. }) => Record<PerformanceWidgetSetting, ChartDefinition> = ({
  70. organization,
  71. }: {
  72. organization: Organization;
  73. }) => ({
  74. [PerformanceWidgetSetting.DURATION_HISTOGRAM]: {
  75. title: t('Duration Distribution'),
  76. titleTooltip: getTermHelp(organization, PerformanceTerm.DURATION_DISTRIBUTION),
  77. fields: ['transaction.duration'],
  78. dataType: GenericPerformanceWidgetDataType.HISTOGRAM,
  79. chartColor: WIDGET_PALETTE[5],
  80. },
  81. [PerformanceWidgetSetting.LCP_HISTOGRAM]: {
  82. title: t('LCP Distribution'),
  83. titleTooltip: getTermHelp(organization, PerformanceTerm.DURATION_DISTRIBUTION),
  84. fields: ['measurements.lcp'],
  85. dataType: GenericPerformanceWidgetDataType.HISTOGRAM,
  86. chartColor: WIDGET_PALETTE[5],
  87. },
  88. [PerformanceWidgetSetting.FCP_HISTOGRAM]: {
  89. title: t('FCP Distribution'),
  90. titleTooltip: getTermHelp(organization, PerformanceTerm.DURATION_DISTRIBUTION),
  91. fields: ['measurements.fcp'],
  92. dataType: GenericPerformanceWidgetDataType.HISTOGRAM,
  93. chartColor: WIDGET_PALETTE[5],
  94. },
  95. [PerformanceWidgetSetting.FID_HISTOGRAM]: {
  96. title: t('FID Distribution'),
  97. titleTooltip: getTermHelp(organization, PerformanceTerm.DURATION_DISTRIBUTION),
  98. fields: ['measurements.fid'],
  99. dataType: GenericPerformanceWidgetDataType.HISTOGRAM,
  100. chartColor: WIDGET_PALETTE[5],
  101. },
  102. [PerformanceWidgetSetting.WORST_LCP_VITALS]: {
  103. title: t('Worst LCP Web Vitals'),
  104. titleTooltip: getTermHelp(organization, PerformanceTerm.LCP),
  105. fields: ['measurements.lcp'],
  106. vitalStops: {
  107. poor: 4000,
  108. meh: 2500,
  109. },
  110. dataType: GenericPerformanceWidgetDataType.VITALS,
  111. },
  112. [PerformanceWidgetSetting.WORST_FCP_VITALS]: {
  113. title: t('Worst FCP Web Vitals'),
  114. titleTooltip: getTermHelp(organization, PerformanceTerm.FCP),
  115. fields: ['measurements.fcp'],
  116. vitalStops: {
  117. poor: 3000,
  118. meh: 1000,
  119. },
  120. dataType: GenericPerformanceWidgetDataType.VITALS,
  121. },
  122. [PerformanceWidgetSetting.WORST_FID_VITALS]: {
  123. title: t('Worst FID Web Vitals'),
  124. titleTooltip: getTermHelp(organization, PerformanceTerm.FID),
  125. fields: ['measurements.fid'],
  126. vitalStops: {
  127. poor: 300,
  128. meh: 100,
  129. },
  130. dataType: GenericPerformanceWidgetDataType.VITALS,
  131. },
  132. [PerformanceWidgetSetting.WORST_CLS_VITALS]: {
  133. title: t('Worst CLS Web Vitals'),
  134. titleTooltip: getTermHelp(organization, PerformanceTerm.CLS),
  135. fields: ['measurements.cls'],
  136. vitalStops: {
  137. poor: 0.25,
  138. meh: 0.1,
  139. },
  140. dataType: GenericPerformanceWidgetDataType.VITALS,
  141. },
  142. [PerformanceWidgetSetting.TPM_AREA]: {
  143. title: t('Transactions Per Minute'),
  144. titleTooltip: getTermHelp(organization, PerformanceTerm.TPM),
  145. fields: ['tpm()'],
  146. dataType: GenericPerformanceWidgetDataType.AREA,
  147. chartColor: WIDGET_PALETTE[1],
  148. allowsOpenInDiscover: true,
  149. },
  150. [PerformanceWidgetSetting.APDEX_AREA]: {
  151. title: t('Apdex'),
  152. titleTooltip: getTermHelp(organization, PerformanceTerm.APDEX),
  153. fields: ['apdex()'],
  154. dataType: GenericPerformanceWidgetDataType.AREA,
  155. chartColor: WIDGET_PALETTE[4],
  156. allowsOpenInDiscover: true,
  157. },
  158. [PerformanceWidgetSetting.P50_DURATION_AREA]: {
  159. title: t('p50 Duration'),
  160. titleTooltip: getTermHelp(organization, PerformanceTerm.P50),
  161. fields: ['p50(transaction.duration)'],
  162. dataType: GenericPerformanceWidgetDataType.AREA,
  163. chartColor: WIDGET_PALETTE[3],
  164. allowsOpenInDiscover: true,
  165. },
  166. [PerformanceWidgetSetting.P75_DURATION_AREA]: {
  167. title: t('p75 Duration'),
  168. titleTooltip: getTermHelp(organization, PerformanceTerm.P75),
  169. fields: ['p75(transaction.duration)'],
  170. dataType: GenericPerformanceWidgetDataType.AREA,
  171. chartColor: WIDGET_PALETTE[3],
  172. allowsOpenInDiscover: true,
  173. },
  174. [PerformanceWidgetSetting.P95_DURATION_AREA]: {
  175. title: t('p95 Duration'),
  176. titleTooltip: getTermHelp(organization, PerformanceTerm.P95),
  177. fields: ['p95(transaction.duration)'],
  178. dataType: GenericPerformanceWidgetDataType.AREA,
  179. chartColor: WIDGET_PALETTE[3],
  180. allowsOpenInDiscover: true,
  181. },
  182. [PerformanceWidgetSetting.P99_DURATION_AREA]: {
  183. title: t('p99 Duration'),
  184. titleTooltip: getTermHelp(organization, PerformanceTerm.P99),
  185. fields: ['p99(transaction.duration)'],
  186. dataType: GenericPerformanceWidgetDataType.AREA,
  187. chartColor: WIDGET_PALETTE[3],
  188. allowsOpenInDiscover: true,
  189. },
  190. [PerformanceWidgetSetting.P75_LCP_AREA]: {
  191. title: t('p75 LCP'),
  192. titleTooltip: getTermHelp(organization, PerformanceTerm.P75),
  193. fields: ['p75(measurements.lcp)'],
  194. dataType: GenericPerformanceWidgetDataType.AREA,
  195. chartColor: WIDGET_PALETTE[1],
  196. allowsOpenInDiscover: true,
  197. },
  198. [PerformanceWidgetSetting.FAILURE_RATE_AREA]: {
  199. title: t('Failure Rate'),
  200. titleTooltip: getTermHelp(organization, PerformanceTerm.FAILURE_RATE),
  201. fields: ['failure_rate()'],
  202. dataType: GenericPerformanceWidgetDataType.AREA,
  203. chartColor: WIDGET_PALETTE[2],
  204. allowsOpenInDiscover: true,
  205. },
  206. [PerformanceWidgetSetting.USER_MISERY_AREA]: {
  207. title: t('User Misery'),
  208. titleTooltip: getTermHelp(organization, PerformanceTerm.USER_MISERY),
  209. fields: [`user_misery()`],
  210. dataType: GenericPerformanceWidgetDataType.AREA,
  211. chartColor: WIDGET_PALETTE[0],
  212. allowsOpenInDiscover: true,
  213. },
  214. [PerformanceWidgetSetting.COLD_STARTUP_AREA]: {
  215. title: t('Cold Startup Time'),
  216. titleTooltip: getTermHelp(organization, PerformanceTerm.APP_START_COLD),
  217. fields: ['p75(measurements.app_start_cold)'],
  218. dataType: GenericPerformanceWidgetDataType.AREA,
  219. chartColor: WIDGET_PALETTE[4],
  220. allowsOpenInDiscover: true,
  221. },
  222. [PerformanceWidgetSetting.WARM_STARTUP_AREA]: {
  223. title: t('Warm Startup Time'),
  224. titleTooltip: getTermHelp(organization, PerformanceTerm.APP_START_WARM),
  225. fields: ['p75(measurements.app_start_warm)'],
  226. dataType: GenericPerformanceWidgetDataType.AREA,
  227. chartColor: WIDGET_PALETTE[3],
  228. allowsOpenInDiscover: true,
  229. },
  230. [PerformanceWidgetSetting.SLOW_FRAMES_AREA]: {
  231. title: t('Slow Frames'),
  232. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_FRAMES),
  233. fields: ['p75(measurements.frames_slow_rate)'],
  234. dataType: GenericPerformanceWidgetDataType.AREA,
  235. chartColor: WIDGET_PALETTE[0],
  236. allowsOpenInDiscover: true,
  237. },
  238. [PerformanceWidgetSetting.FROZEN_FRAMES_AREA]: {
  239. title: t('Frozen Frames'),
  240. titleTooltip: getTermHelp(organization, PerformanceTerm.FROZEN_FRAMES),
  241. fields: ['p75(measurements.frames_frozen_rate)'],
  242. dataType: GenericPerformanceWidgetDataType.AREA,
  243. chartColor: WIDGET_PALETTE[5],
  244. allowsOpenInDiscover: true,
  245. },
  246. [PerformanceWidgetSetting.MOST_RELATED_ERRORS]: {
  247. title: t('Most Related Errors'),
  248. titleTooltip: getTermHelp(organization, PerformanceTerm.MOST_ERRORS),
  249. fields: [`failure_count()`],
  250. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  251. chartColor: WIDGET_PALETTE[0],
  252. },
  253. [PerformanceWidgetSetting.MOST_RELATED_ISSUES]: {
  254. title: t('Most Related Issues'),
  255. titleTooltip: getTermHelp(organization, PerformanceTerm.MOST_ISSUES),
  256. fields: [`count()`],
  257. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  258. chartColor: WIDGET_PALETTE[0],
  259. },
  260. [PerformanceWidgetSetting.MOST_TIME_SPENT_DB_QUERIES]: {
  261. title: t('Most Time-Consuming Queries'),
  262. subTitle: t('Top queries by total duration'),
  263. titleTooltip: getTermHelp(organization, PerformanceTerm.MOST_TIME_SPENT_DB_QUERIES),
  264. fields: [`time_spent_percentage()`],
  265. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  266. chartColor: WIDGET_PALETTE[0],
  267. },
  268. [PerformanceWidgetSetting.MOST_TIME_CONSUMING_RESOURCES]: {
  269. title: t('Most Time Consuming Resources'),
  270. subTitle: t('Render blocking for pages'),
  271. titleTooltip: getTermHelp(
  272. organization,
  273. PerformanceTerm.MOST_TIME_CONSUMING_RESOURCES
  274. ),
  275. fields: [`time_spent_percentage()`],
  276. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  277. chartColor: WIDGET_PALETTE[0],
  278. },
  279. [PerformanceWidgetSetting.HIGHEST_OPPORTUNITY_PAGES]: {
  280. title: t('Best Page Opportunities'),
  281. subTitle: t('Pages to improve your performance score'),
  282. titleTooltip: '',
  283. fields: [`count()`],
  284. dataType: GenericPerformanceWidgetDataType.PERFORMANCE_SCORE_LIST,
  285. },
  286. [PerformanceWidgetSetting.OVERALL_PERFORMANCE_SCORE]: {
  287. title: t('Performance Score'),
  288. subTitle: t('The overall performance score across selected frontend projects only'),
  289. titleTooltip: '',
  290. fields: [],
  291. dataType: GenericPerformanceWidgetDataType.PERFORMANCE_SCORE,
  292. },
  293. [PerformanceWidgetSetting.SLOW_HTTP_OPS]: {
  294. title: t('Slow HTTP Ops'),
  295. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_HTTP_SPANS),
  296. fields: [`p75(spans.http)`, 'p75(spans.db)'],
  297. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  298. chartColor: WIDGET_PALETTE[0],
  299. },
  300. [PerformanceWidgetSetting.SLOW_BROWSER_OPS]: {
  301. title: t('Slow Browser Ops'),
  302. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_HTTP_SPANS),
  303. fields: [`p75(spans.browser)`],
  304. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  305. chartColor: WIDGET_PALETTE[0],
  306. },
  307. [PerformanceWidgetSetting.SLOW_RESOURCE_OPS]: {
  308. title: t('Slow Resource Ops'),
  309. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_HTTP_SPANS),
  310. fields: [`p75(spans.resource)`],
  311. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  312. chartColor: WIDGET_PALETTE[0],
  313. },
  314. [PerformanceWidgetSetting.SLOW_DB_OPS]: {
  315. title: t('Slow DB Ops'),
  316. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_HTTP_SPANS),
  317. fields: [`p75(spans.db)`, 'p75(spans.http)'],
  318. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  319. chartColor: WIDGET_PALETTE[0],
  320. },
  321. [PerformanceWidgetSetting.TIME_TO_INITIAL_DISPLAY]: {
  322. title: t('Time to Initial Display'),
  323. titleTooltip: getTermHelp(organization, PerformanceTerm.TIME_TO_INITIAL_DISPLAY),
  324. fields: ['p75(measurements.time_to_initial_display)'],
  325. dataType: GenericPerformanceWidgetDataType.AREA,
  326. chartColor: WIDGET_PALETTE[4],
  327. allowsOpenInDiscover: true,
  328. },
  329. [PerformanceWidgetSetting.TIME_TO_FULL_DISPLAY]: {
  330. title: t('Time to Full Display'),
  331. titleTooltip: getTermHelp(organization, PerformanceTerm.TIME_TO_FULL_DISPLAY),
  332. fields: ['p75(measurements.time_to_full_display)'],
  333. dataType: GenericPerformanceWidgetDataType.AREA,
  334. chartColor: WIDGET_PALETTE[4],
  335. allowsOpenInDiscover: true,
  336. },
  337. [PerformanceWidgetSetting.MOST_SLOW_FRAMES]: {
  338. title: t('Most Slow Frames'),
  339. titleTooltip: getTermHelp(organization, PerformanceTerm.SLOW_FRAMES),
  340. fields: ['avg(measurements.frames_slow)'],
  341. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  342. chartColor: WIDGET_PALETTE[0],
  343. },
  344. [PerformanceWidgetSetting.MOST_FROZEN_FRAMES]: {
  345. title: t('Most Frozen Frames'),
  346. titleTooltip: getTermHelp(organization, PerformanceTerm.FROZEN_FRAMES),
  347. fields: ['avg(measurements.frames_frozen)'],
  348. dataType: GenericPerformanceWidgetDataType.LINE_LIST,
  349. chartColor: WIDGET_PALETTE[0],
  350. },
  351. [PerformanceWidgetSetting.MOST_IMPROVED]: {
  352. title: t('Most Improved'),
  353. titleTooltip: t(
  354. 'This compares the baseline (%s) of the past with the present.',
  355. 'improved'
  356. ),
  357. fields: [],
  358. dataType: GenericPerformanceWidgetDataType.TRENDS,
  359. },
  360. [PerformanceWidgetSetting.MOST_REGRESSED]: {
  361. title: t('Most Regressed'),
  362. titleTooltip: t(
  363. 'This compares the baseline (%s) of the past with the present.',
  364. 'regressed'
  365. ),
  366. fields: [],
  367. dataType: GenericPerformanceWidgetDataType.TRENDS,
  368. },
  369. [PerformanceWidgetSetting.MOST_CHANGED]: {
  370. title: t('Most Changed'),
  371. titleTooltip: t(
  372. 'This compares the baseline (%s) of the past with the present.',
  373. 'changed'
  374. ),
  375. fields: [],
  376. dataType: GenericPerformanceWidgetDataType.TRENDS,
  377. },
  378. [PerformanceWidgetSetting.SPAN_OPERATIONS]: {
  379. title: t('Span Operations Breakdown'),
  380. titleTooltip: '',
  381. fields: SPAN_OP_BREAKDOWN_FIELDS.map(spanOp => `p75(${spanOp})`),
  382. dataType: GenericPerformanceWidgetDataType.STACKED_AREA,
  383. },
  384. [PerformanceWidgetSetting.SLOW_SCREENS_BY_TTID]: {
  385. title: t('Average TTIDs'),
  386. titleTooltip: '',
  387. subTitle: t('Top screens by count'),
  388. fields: ['avg(measurements.time_to_initial_display)'],
  389. dataType: GenericPerformanceWidgetDataType.SLOW_SCREENS_BY_TTID,
  390. },
  391. });