widgetDefinitions.tsx 13 KB

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