widgetDefinitions.tsx 14 KB

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