widgetDefinitions.tsx 11 KB

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