widgetDefinitions.tsx 13 KB

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