widgetDefinitions.tsx 14 KB

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