widgetDefinitions.tsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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, PERFORMANCE_TERM} from '../../data';
  6. import {GenericPerformanceWidgetDataType} from './types';
  7. export interface ChartDefinition {
  8. dataType: GenericPerformanceWidgetDataType;
  9. fields: string[];
  10. title: string;
  11. titleTooltip: string; // The first field in the list will be treated as the primary field in most widgets (except for special casing).
  12. allowsOpenInDiscover?: boolean;
  13. chartColor?: string; // Optional. Will default to colors depending on placement in list or colors from the chart itself.
  14. vitalStops?: {
  15. meh: number;
  16. poor: number;
  17. };
  18. }
  19. export enum PerformanceWidgetSetting {
  20. DURATION_HISTOGRAM = 'duration_histogram',
  21. LCP_HISTOGRAM = 'lcp_histogram',
  22. FCP_HISTOGRAM = 'fcp_histogram',
  23. FID_HISTOGRAM = 'fid_histogram',
  24. APDEX_AREA = 'apdex_area',
  25. P50_DURATION_AREA = 'p50_duration_area',
  26. P75_DURATION_AREA = 'p75_duration_area',
  27. P95_DURATION_AREA = 'p95_duration_area',
  28. P99_DURATION_AREA = 'p99_duration_area',
  29. P75_LCP_AREA = 'p75_lcp_area',
  30. TPM_AREA = 'tpm_area',
  31. FAILURE_RATE_AREA = 'failure_rate_area',
  32. USER_MISERY_AREA = 'user_misery_area',
  33. WORST_LCP_VITALS = 'worst_lcp_vitals',
  34. WORST_FCP_VITALS = 'worst_fcp_vitals',
  35. WORST_CLS_VITALS = 'worst_cls_vitals',
  36. WORST_FID_VITALS = 'worst_fid_vitals',
  37. MOST_IMPROVED = 'most_improved',
  38. MOST_REGRESSED = 'most_regressed',
  39. MOST_RELATED_ERRORS = 'most_related_errors',
  40. MOST_RELATED_ISSUES = 'most_related_issues',
  41. SLOW_HTTP_OPS = 'slow_http_ops',
  42. SLOW_DB_OPS = 'slow_db_ops',
  43. SLOW_RESOURCE_OPS = 'slow_resource_ops',
  44. SLOW_BROWSER_OPS = 'slow_browser_ops',
  45. COLD_STARTUP_AREA = 'cold_startup_area',
  46. WARM_STARTUP_AREA = 'warm_startup_area',
  47. SLOW_FRAMES_AREA = 'slow_frames_area',
  48. FROZEN_FRAMES_AREA = 'frozen_frames_area',
  49. MOST_SLOW_FRAMES = 'most_slow_frames',
  50. MOST_FROZEN_FRAMES = 'most_frozen_frames',
  51. SPAN_OPERATIONS = 'span_operations',
  52. TIME_TO_INITIAL_DISPLAY = 'time_to_initial_display',
  53. TIME_TO_FULL_DISPLAY = 'time_to_full_display',
  54. }
  55. const WIDGET_PALETTE = CHART_PALETTE[5];
  56. export const WIDGET_DEFINITIONS: ({
  57. organization,
  58. }: {
  59. organization: Organization;
  60. }) => Record<PerformanceWidgetSetting, ChartDefinition> = ({
  61. organization,
  62. }: {
  63. organization: Organization;
  64. }) => ({
  65. [PerformanceWidgetSetting.DURATION_HISTOGRAM]: {
  66. title: t('Duration Distribution'),
  67. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  68. fields: ['transaction.duration'],
  69. dataType: GenericPerformanceWidgetDataType.histogram,
  70. chartColor: WIDGET_PALETTE[5],
  71. },
  72. [PerformanceWidgetSetting.LCP_HISTOGRAM]: {
  73. title: t('LCP Distribution'),
  74. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  75. fields: ['measurements.lcp'],
  76. dataType: GenericPerformanceWidgetDataType.histogram,
  77. chartColor: WIDGET_PALETTE[5],
  78. },
  79. [PerformanceWidgetSetting.FCP_HISTOGRAM]: {
  80. title: t('FCP Distribution'),
  81. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  82. fields: ['measurements.fcp'],
  83. dataType: GenericPerformanceWidgetDataType.histogram,
  84. chartColor: WIDGET_PALETTE[5],
  85. },
  86. [PerformanceWidgetSetting.FID_HISTOGRAM]: {
  87. title: t('FID Distribution'),
  88. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  89. fields: ['measurements.fid'],
  90. dataType: GenericPerformanceWidgetDataType.histogram,
  91. chartColor: WIDGET_PALETTE[5],
  92. },
  93. [PerformanceWidgetSetting.WORST_LCP_VITALS]: {
  94. title: t('Worst LCP Web Vitals'),
  95. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.LCP),
  96. fields: ['measurements.lcp'],
  97. vitalStops: {
  98. poor: 4000,
  99. meh: 2500,
  100. },
  101. dataType: GenericPerformanceWidgetDataType.vitals,
  102. },
  103. [PerformanceWidgetSetting.WORST_FCP_VITALS]: {
  104. title: t('Worst FCP Web Vitals'),
  105. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FCP),
  106. fields: ['measurements.fcp'],
  107. vitalStops: {
  108. poor: 3000,
  109. meh: 1000,
  110. },
  111. dataType: GenericPerformanceWidgetDataType.vitals,
  112. },
  113. [PerformanceWidgetSetting.WORST_FID_VITALS]: {
  114. title: t('Worst FID Web Vitals'),
  115. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FID),
  116. fields: ['measurements.fid'],
  117. vitalStops: {
  118. poor: 300,
  119. meh: 100,
  120. },
  121. dataType: GenericPerformanceWidgetDataType.vitals,
  122. },
  123. [PerformanceWidgetSetting.WORST_CLS_VITALS]: {
  124. title: t('Worst CLS Web Vitals'),
  125. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.CLS),
  126. fields: ['measurements.cls'],
  127. vitalStops: {
  128. poor: 0.25,
  129. meh: 0.1,
  130. },
  131. dataType: GenericPerformanceWidgetDataType.vitals,
  132. },
  133. [PerformanceWidgetSetting.TPM_AREA]: {
  134. title: t('Transactions Per Minute'),
  135. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.TPM),
  136. fields: ['tpm()'],
  137. dataType: GenericPerformanceWidgetDataType.area,
  138. chartColor: WIDGET_PALETTE[1],
  139. allowsOpenInDiscover: true,
  140. },
  141. [PerformanceWidgetSetting.APDEX_AREA]: {
  142. title: t('Apdex'),
  143. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.APDEX),
  144. fields: ['apdex()'],
  145. dataType: GenericPerformanceWidgetDataType.area,
  146. chartColor: WIDGET_PALETTE[4],
  147. allowsOpenInDiscover: true,
  148. },
  149. [PerformanceWidgetSetting.P50_DURATION_AREA]: {
  150. title: t('p50 Duration'),
  151. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P50),
  152. fields: ['p50(transaction.duration)'],
  153. dataType: GenericPerformanceWidgetDataType.area,
  154. chartColor: WIDGET_PALETTE[3],
  155. allowsOpenInDiscover: true,
  156. },
  157. [PerformanceWidgetSetting.P75_DURATION_AREA]: {
  158. title: t('p75 Duration'),
  159. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P75),
  160. fields: ['p75(transaction.duration)'],
  161. dataType: GenericPerformanceWidgetDataType.area,
  162. chartColor: WIDGET_PALETTE[3],
  163. allowsOpenInDiscover: true,
  164. },
  165. [PerformanceWidgetSetting.P95_DURATION_AREA]: {
  166. title: t('p95 Duration'),
  167. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P95),
  168. fields: ['p95(transaction.duration)'],
  169. dataType: GenericPerformanceWidgetDataType.area,
  170. chartColor: WIDGET_PALETTE[3],
  171. allowsOpenInDiscover: true,
  172. },
  173. [PerformanceWidgetSetting.P99_DURATION_AREA]: {
  174. title: t('p99 Duration'),
  175. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P99),
  176. fields: ['p99(transaction.duration)'],
  177. dataType: GenericPerformanceWidgetDataType.area,
  178. chartColor: WIDGET_PALETTE[3],
  179. allowsOpenInDiscover: true,
  180. },
  181. [PerformanceWidgetSetting.P75_LCP_AREA]: {
  182. title: t('p75 LCP'),
  183. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P75),
  184. fields: ['p75(measurements.lcp)'],
  185. dataType: GenericPerformanceWidgetDataType.area,
  186. chartColor: WIDGET_PALETTE[1],
  187. allowsOpenInDiscover: true,
  188. },
  189. [PerformanceWidgetSetting.FAILURE_RATE_AREA]: {
  190. title: t('Failure Rate'),
  191. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FAILURE_RATE),
  192. fields: ['failure_rate()'],
  193. dataType: GenericPerformanceWidgetDataType.area,
  194. chartColor: WIDGET_PALETTE[2],
  195. allowsOpenInDiscover: true,
  196. },
  197. [PerformanceWidgetSetting.USER_MISERY_AREA]: {
  198. title: t('User Misery'),
  199. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.USER_MISERY),
  200. fields: [`user_misery()`],
  201. dataType: GenericPerformanceWidgetDataType.area,
  202. chartColor: WIDGET_PALETTE[0],
  203. allowsOpenInDiscover: true,
  204. },
  205. [PerformanceWidgetSetting.COLD_STARTUP_AREA]: {
  206. title: t('Cold Startup Time'),
  207. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.APP_START_COLD),
  208. fields: ['p75(measurements.app_start_cold)'],
  209. dataType: GenericPerformanceWidgetDataType.area,
  210. chartColor: WIDGET_PALETTE[4],
  211. allowsOpenInDiscover: true,
  212. },
  213. [PerformanceWidgetSetting.WARM_STARTUP_AREA]: {
  214. title: t('Warm Startup Time'),
  215. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.APP_START_WARM),
  216. fields: ['p75(measurements.app_start_warm)'],
  217. dataType: GenericPerformanceWidgetDataType.area,
  218. chartColor: WIDGET_PALETTE[3],
  219. allowsOpenInDiscover: true,
  220. },
  221. [PerformanceWidgetSetting.SLOW_FRAMES_AREA]: {
  222. title: t('Slow Frames'),
  223. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_FRAMES),
  224. fields: ['p75(measurements.frames_slow_rate)'],
  225. dataType: GenericPerformanceWidgetDataType.area,
  226. chartColor: WIDGET_PALETTE[0],
  227. allowsOpenInDiscover: true,
  228. },
  229. [PerformanceWidgetSetting.FROZEN_FRAMES_AREA]: {
  230. title: t('Frozen Frames'),
  231. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FROZEN_FRAMES),
  232. fields: ['p75(measurements.frames_frozen_rate)'],
  233. dataType: GenericPerformanceWidgetDataType.area,
  234. chartColor: WIDGET_PALETTE[5],
  235. allowsOpenInDiscover: true,
  236. },
  237. [PerformanceWidgetSetting.MOST_RELATED_ERRORS]: {
  238. title: t('Most Related Errors'),
  239. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.MOST_ERRORS),
  240. fields: [`failure_count()`],
  241. dataType: GenericPerformanceWidgetDataType.line_list,
  242. chartColor: WIDGET_PALETTE[0],
  243. },
  244. [PerformanceWidgetSetting.MOST_RELATED_ISSUES]: {
  245. title: t('Most Related Issues'),
  246. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.MOST_ISSUES),
  247. fields: [`count()`],
  248. dataType: GenericPerformanceWidgetDataType.line_list,
  249. chartColor: WIDGET_PALETTE[0],
  250. },
  251. [PerformanceWidgetSetting.SLOW_HTTP_OPS]: {
  252. title: t('Slow HTTP Ops'),
  253. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_HTTP_SPANS),
  254. fields: [`p75(spans.http)`],
  255. dataType: GenericPerformanceWidgetDataType.line_list,
  256. chartColor: WIDGET_PALETTE[0],
  257. },
  258. [PerformanceWidgetSetting.SLOW_BROWSER_OPS]: {
  259. title: t('Slow Browser Ops'),
  260. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_HTTP_SPANS),
  261. fields: [`p75(spans.browser)`],
  262. dataType: GenericPerformanceWidgetDataType.line_list,
  263. chartColor: WIDGET_PALETTE[0],
  264. },
  265. [PerformanceWidgetSetting.SLOW_RESOURCE_OPS]: {
  266. title: t('Slow Resource Ops'),
  267. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_HTTP_SPANS),
  268. fields: [`p75(spans.resource)`],
  269. dataType: GenericPerformanceWidgetDataType.line_list,
  270. chartColor: WIDGET_PALETTE[0],
  271. },
  272. [PerformanceWidgetSetting.SLOW_DB_OPS]: {
  273. title: t('Slow DB Ops'),
  274. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_HTTP_SPANS),
  275. fields: [`p75(spans.db)`],
  276. dataType: GenericPerformanceWidgetDataType.line_list,
  277. chartColor: WIDGET_PALETTE[0],
  278. },
  279. [PerformanceWidgetSetting.TIME_TO_INITIAL_DISPLAY]: {
  280. title: t('Time to Initial Display'),
  281. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.TIME_TO_INITIAL_DISPLAY),
  282. fields: ['p75(measurements.time_to_initial_display)'],
  283. dataType: GenericPerformanceWidgetDataType.area,
  284. chartColor: WIDGET_PALETTE[4],
  285. allowsOpenInDiscover: true,
  286. },
  287. [PerformanceWidgetSetting.TIME_TO_FULL_DISPLAY]: {
  288. title: t('Time to Full Display'),
  289. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.TIME_TO_FULL_DISPLAY),
  290. fields: ['p75(measurements.time_to_full_display)'],
  291. dataType: GenericPerformanceWidgetDataType.area,
  292. chartColor: WIDGET_PALETTE[4],
  293. allowsOpenInDiscover: true,
  294. },
  295. [PerformanceWidgetSetting.MOST_SLOW_FRAMES]: {
  296. title: t('Most Slow Frames'),
  297. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_FRAMES),
  298. fields: ['avg(measurements.frames_slow)'],
  299. dataType: GenericPerformanceWidgetDataType.line_list,
  300. chartColor: WIDGET_PALETTE[0],
  301. },
  302. [PerformanceWidgetSetting.MOST_FROZEN_FRAMES]: {
  303. title: t('Most Frozen Frames'),
  304. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FROZEN_FRAMES),
  305. fields: ['avg(measurements.frames_frozen)'],
  306. dataType: GenericPerformanceWidgetDataType.line_list,
  307. chartColor: WIDGET_PALETTE[0],
  308. },
  309. [PerformanceWidgetSetting.MOST_IMPROVED]: {
  310. title: t('Most Improved'),
  311. titleTooltip: t(
  312. 'This compares the baseline (%s) of the past with the present.',
  313. 'improved'
  314. ),
  315. fields: [],
  316. dataType: GenericPerformanceWidgetDataType.trends,
  317. },
  318. [PerformanceWidgetSetting.MOST_REGRESSED]: {
  319. title: t('Most Regressed'),
  320. titleTooltip: t(
  321. 'This compares the baseline (%s) of the past with the present.',
  322. 'regressed'
  323. ),
  324. fields: [],
  325. dataType: GenericPerformanceWidgetDataType.trends,
  326. },
  327. [PerformanceWidgetSetting.SPAN_OPERATIONS]: {
  328. title: t('Span Operations Breakdown'),
  329. titleTooltip: '',
  330. fields: SPAN_OP_BREAKDOWN_FIELDS.map(spanOp => `p75(${spanOp})`),
  331. dataType: GenericPerformanceWidgetDataType.stacked_area,
  332. },
  333. });