widgetDefinitions.tsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. }
  53. const WIDGET_PALETTE = CHART_PALETTE[5];
  54. export const WIDGET_DEFINITIONS: ({
  55. organization,
  56. }: {
  57. organization: Organization;
  58. }) => Record<PerformanceWidgetSetting, ChartDefinition> = ({
  59. organization,
  60. }: {
  61. organization: Organization;
  62. }) => ({
  63. [PerformanceWidgetSetting.DURATION_HISTOGRAM]: {
  64. title: t('Duration Distribution'),
  65. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  66. fields: ['transaction.duration'],
  67. dataType: GenericPerformanceWidgetDataType.histogram,
  68. chartColor: WIDGET_PALETTE[5],
  69. },
  70. [PerformanceWidgetSetting.LCP_HISTOGRAM]: {
  71. title: t('LCP Distribution'),
  72. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  73. fields: ['measurements.lcp'],
  74. dataType: GenericPerformanceWidgetDataType.histogram,
  75. chartColor: WIDGET_PALETTE[5],
  76. },
  77. [PerformanceWidgetSetting.FCP_HISTOGRAM]: {
  78. title: t('FCP Distribution'),
  79. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  80. fields: ['measurements.fcp'],
  81. dataType: GenericPerformanceWidgetDataType.histogram,
  82. chartColor: WIDGET_PALETTE[5],
  83. },
  84. [PerformanceWidgetSetting.FID_HISTOGRAM]: {
  85. title: t('FID Distribution'),
  86. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  87. fields: ['measurements.fid'],
  88. dataType: GenericPerformanceWidgetDataType.histogram,
  89. chartColor: WIDGET_PALETTE[5],
  90. },
  91. [PerformanceWidgetSetting.WORST_LCP_VITALS]: {
  92. title: t('Worst LCP Web Vitals'),
  93. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.LCP),
  94. fields: ['measurements.lcp'],
  95. vitalStops: {
  96. poor: 4000,
  97. meh: 2500,
  98. },
  99. dataType: GenericPerformanceWidgetDataType.vitals,
  100. },
  101. [PerformanceWidgetSetting.WORST_FCP_VITALS]: {
  102. title: t('Worst FCP Web Vitals'),
  103. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FCP),
  104. fields: ['measurements.fcp'],
  105. vitalStops: {
  106. poor: 3000,
  107. meh: 1000,
  108. },
  109. dataType: GenericPerformanceWidgetDataType.vitals,
  110. },
  111. [PerformanceWidgetSetting.WORST_FID_VITALS]: {
  112. title: t('Worst FID Web Vitals'),
  113. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FID),
  114. fields: ['measurements.fid'],
  115. vitalStops: {
  116. poor: 300,
  117. meh: 100,
  118. },
  119. dataType: GenericPerformanceWidgetDataType.vitals,
  120. },
  121. [PerformanceWidgetSetting.WORST_CLS_VITALS]: {
  122. title: t('Worst CLS Web Vitals'),
  123. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.CLS),
  124. fields: ['measurements.cls'],
  125. vitalStops: {
  126. poor: 0.25,
  127. meh: 0.1,
  128. },
  129. dataType: GenericPerformanceWidgetDataType.vitals,
  130. },
  131. [PerformanceWidgetSetting.TPM_AREA]: {
  132. title: t('Transactions Per Minute'),
  133. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.TPM),
  134. fields: ['tpm()'],
  135. dataType: GenericPerformanceWidgetDataType.area,
  136. chartColor: WIDGET_PALETTE[1],
  137. allowsOpenInDiscover: true,
  138. },
  139. [PerformanceWidgetSetting.APDEX_AREA]: {
  140. title: t('Apdex'),
  141. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.APDEX),
  142. fields: ['apdex()'],
  143. dataType: GenericPerformanceWidgetDataType.area,
  144. chartColor: WIDGET_PALETTE[4],
  145. allowsOpenInDiscover: true,
  146. },
  147. [PerformanceWidgetSetting.P50_DURATION_AREA]: {
  148. title: t('p50 Duration'),
  149. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P50),
  150. fields: ['p50(transaction.duration)'],
  151. dataType: GenericPerformanceWidgetDataType.area,
  152. chartColor: WIDGET_PALETTE[3],
  153. allowsOpenInDiscover: true,
  154. },
  155. [PerformanceWidgetSetting.P75_DURATION_AREA]: {
  156. title: t('p75 Duration'),
  157. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P75),
  158. fields: ['p75(transaction.duration)'],
  159. dataType: GenericPerformanceWidgetDataType.area,
  160. chartColor: WIDGET_PALETTE[3],
  161. allowsOpenInDiscover: true,
  162. },
  163. [PerformanceWidgetSetting.P95_DURATION_AREA]: {
  164. title: t('p95 Duration'),
  165. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P95),
  166. fields: ['p95(transaction.duration)'],
  167. dataType: GenericPerformanceWidgetDataType.area,
  168. chartColor: WIDGET_PALETTE[3],
  169. allowsOpenInDiscover: true,
  170. },
  171. [PerformanceWidgetSetting.P99_DURATION_AREA]: {
  172. title: t('p99 Duration'),
  173. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P99),
  174. fields: ['p99(transaction.duration)'],
  175. dataType: GenericPerformanceWidgetDataType.area,
  176. chartColor: WIDGET_PALETTE[3],
  177. allowsOpenInDiscover: true,
  178. },
  179. [PerformanceWidgetSetting.P75_LCP_AREA]: {
  180. title: t('p75 LCP'),
  181. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.P75),
  182. fields: ['p75(measurements.lcp)'],
  183. dataType: GenericPerformanceWidgetDataType.area,
  184. chartColor: WIDGET_PALETTE[1],
  185. allowsOpenInDiscover: true,
  186. },
  187. [PerformanceWidgetSetting.FAILURE_RATE_AREA]: {
  188. title: t('Failure Rate'),
  189. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FAILURE_RATE),
  190. fields: ['failure_rate()'],
  191. dataType: GenericPerformanceWidgetDataType.area,
  192. chartColor: WIDGET_PALETTE[2],
  193. allowsOpenInDiscover: true,
  194. },
  195. [PerformanceWidgetSetting.USER_MISERY_AREA]: {
  196. title: t('User Misery'),
  197. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.USER_MISERY),
  198. fields: [`user_misery()`],
  199. dataType: GenericPerformanceWidgetDataType.area,
  200. chartColor: WIDGET_PALETTE[0],
  201. allowsOpenInDiscover: true,
  202. },
  203. [PerformanceWidgetSetting.COLD_STARTUP_AREA]: {
  204. title: t('Cold Startup Time'),
  205. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.APP_START_COLD),
  206. fields: ['p75(measurements.app_start_cold)'],
  207. dataType: GenericPerformanceWidgetDataType.area,
  208. chartColor: WIDGET_PALETTE[4],
  209. allowsOpenInDiscover: true,
  210. },
  211. [PerformanceWidgetSetting.WARM_STARTUP_AREA]: {
  212. title: t('Warm Startup Time'),
  213. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.APP_START_WARM),
  214. fields: ['p75(measurements.app_start_warm)'],
  215. dataType: GenericPerformanceWidgetDataType.area,
  216. chartColor: WIDGET_PALETTE[3],
  217. allowsOpenInDiscover: true,
  218. },
  219. [PerformanceWidgetSetting.SLOW_FRAMES_AREA]: {
  220. title: t('Slow Frames'),
  221. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_FRAMES),
  222. fields: ['p75(measurements.frames_slow_rate)'],
  223. dataType: GenericPerformanceWidgetDataType.area,
  224. chartColor: WIDGET_PALETTE[0],
  225. allowsOpenInDiscover: true,
  226. },
  227. [PerformanceWidgetSetting.FROZEN_FRAMES_AREA]: {
  228. title: t('Frozen Frames'),
  229. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FROZEN_FRAMES),
  230. fields: ['p75(measurements.frames_frozen_rate)'],
  231. dataType: GenericPerformanceWidgetDataType.area,
  232. chartColor: WIDGET_PALETTE[5],
  233. allowsOpenInDiscover: true,
  234. },
  235. [PerformanceWidgetSetting.MOST_RELATED_ERRORS]: {
  236. title: t('Most Related Errors'),
  237. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.MOST_ERRORS),
  238. fields: [`failure_count()`],
  239. dataType: GenericPerformanceWidgetDataType.line_list,
  240. chartColor: WIDGET_PALETTE[0],
  241. },
  242. [PerformanceWidgetSetting.MOST_RELATED_ISSUES]: {
  243. title: t('Most Related Issues'),
  244. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.MOST_ISSUES),
  245. fields: [`count()`],
  246. dataType: GenericPerformanceWidgetDataType.line_list,
  247. chartColor: WIDGET_PALETTE[0],
  248. },
  249. [PerformanceWidgetSetting.SLOW_HTTP_OPS]: {
  250. title: t('Slow HTTP Ops'),
  251. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_HTTP_SPANS),
  252. fields: [`p75(spans.http)`],
  253. dataType: GenericPerformanceWidgetDataType.line_list,
  254. chartColor: WIDGET_PALETTE[0],
  255. },
  256. [PerformanceWidgetSetting.SLOW_BROWSER_OPS]: {
  257. title: t('Slow Browser Ops'),
  258. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_HTTP_SPANS),
  259. fields: [`p75(spans.browser)`],
  260. dataType: GenericPerformanceWidgetDataType.line_list,
  261. chartColor: WIDGET_PALETTE[0],
  262. },
  263. [PerformanceWidgetSetting.SLOW_RESOURCE_OPS]: {
  264. title: t('Slow Resource Ops'),
  265. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_HTTP_SPANS),
  266. fields: [`p75(spans.resource)`],
  267. dataType: GenericPerformanceWidgetDataType.line_list,
  268. chartColor: WIDGET_PALETTE[0],
  269. },
  270. [PerformanceWidgetSetting.SLOW_DB_OPS]: {
  271. title: t('Slow DB Ops'),
  272. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_HTTP_SPANS),
  273. fields: [`p75(spans.db)`],
  274. dataType: GenericPerformanceWidgetDataType.line_list,
  275. chartColor: WIDGET_PALETTE[0],
  276. },
  277. [PerformanceWidgetSetting.MOST_SLOW_FRAMES]: {
  278. title: t('Most Slow Frames'),
  279. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.SLOW_FRAMES),
  280. fields: ['avg(measurements.frames_slow)'],
  281. dataType: GenericPerformanceWidgetDataType.line_list,
  282. chartColor: WIDGET_PALETTE[0],
  283. },
  284. [PerformanceWidgetSetting.MOST_FROZEN_FRAMES]: {
  285. title: t('Most Frozen Frames'),
  286. titleTooltip: getTermHelp(organization, PERFORMANCE_TERM.FROZEN_FRAMES),
  287. fields: ['avg(measurements.frames_frozen)'],
  288. dataType: GenericPerformanceWidgetDataType.line_list,
  289. chartColor: WIDGET_PALETTE[0],
  290. },
  291. [PerformanceWidgetSetting.MOST_IMPROVED]: {
  292. title: t('Most Improved'),
  293. titleTooltip: t(
  294. 'This compares the baseline (%s) of the past with the present.',
  295. 'improved'
  296. ),
  297. fields: [],
  298. dataType: GenericPerformanceWidgetDataType.trends,
  299. },
  300. [PerformanceWidgetSetting.MOST_REGRESSED]: {
  301. title: t('Most Regressed'),
  302. titleTooltip: t(
  303. 'This compares the baseline (%s) of the past with the present.',
  304. 'regressed'
  305. ),
  306. fields: [],
  307. dataType: GenericPerformanceWidgetDataType.trends,
  308. },
  309. [PerformanceWidgetSetting.SPAN_OPERATIONS]: {
  310. title: t('Span Operations'),
  311. titleTooltip: '',
  312. fields: SPAN_OP_BREAKDOWN_FIELDS.map(spanOp => `p75(${spanOp})`),
  313. dataType: GenericPerformanceWidgetDataType.stacked_bars,
  314. },
  315. });