widgetDefinitions.tsx 11 KB

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