widgetDefinitions.tsx 13 KB

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