metrics.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. // Totals will not be correct for all aggregation functions.
  2. // Consider adding aggregation specific fixture (e.g. MetricsP75Field) if your test depends on it.
  3. import type {MetricsApiResponse} from 'sentry/types';
  4. export function MetricsField(
  5. field: string,
  6. params: Partial<MetricsApiResponse> = {}
  7. ): MetricsApiResponse {
  8. return {
  9. start: '2021-12-01T16:15:00Z',
  10. end: '2021-12-02T16:15:00Z',
  11. query: '',
  12. meta: [],
  13. intervals: [
  14. '2021-12-01T16:15:00Z',
  15. '2021-12-01T16:30:00Z',
  16. '2021-12-01T16:45:00Z',
  17. '2021-12-01T17:00:00Z',
  18. '2021-12-01T17:15:00Z',
  19. '2021-12-01T17:30:00Z',
  20. '2021-12-01T17:45:00Z',
  21. '2021-12-01T18:00:00Z',
  22. '2021-12-01T18:15:00Z',
  23. '2021-12-01T18:30:00Z',
  24. '2021-12-01T18:45:00Z',
  25. '2021-12-01T19:00:00Z',
  26. '2021-12-01T19:15:00Z',
  27. '2021-12-01T19:30:00Z',
  28. '2021-12-01T19:45:00Z',
  29. '2021-12-01T20:00:00Z',
  30. '2021-12-01T20:15:00Z',
  31. '2021-12-01T20:30:00Z',
  32. '2021-12-01T20:45:00Z',
  33. '2021-12-01T21:00:00Z',
  34. '2021-12-01T21:15:00Z',
  35. '2021-12-01T21:30:00Z',
  36. '2021-12-01T21:45:00Z',
  37. '2021-12-01T22:00:00Z',
  38. '2021-12-01T22:15:00Z',
  39. '2021-12-01T22:30:00Z',
  40. '2021-12-01T22:45:00Z',
  41. '2021-12-01T23:00:00Z',
  42. '2021-12-01T23:15:00Z',
  43. '2021-12-01T23:30:00Z',
  44. '2021-12-01T23:45:00Z',
  45. '2021-12-02T00:00:00Z',
  46. '2021-12-02T00:15:00Z',
  47. '2021-12-02T00:30:00Z',
  48. '2021-12-02T00:45:00Z',
  49. '2021-12-02T01:00:00Z',
  50. '2021-12-02T01:15:00Z',
  51. '2021-12-02T01:30:00Z',
  52. '2021-12-02T01:45:00Z',
  53. '2021-12-02T02:00:00Z',
  54. '2021-12-02T02:15:00Z',
  55. '2021-12-02T02:30:00Z',
  56. '2021-12-02T02:45:00Z',
  57. '2021-12-02T03:00:00Z',
  58. '2021-12-02T03:15:00Z',
  59. '2021-12-02T03:30:00Z',
  60. '2021-12-02T03:45:00Z',
  61. '2021-12-02T04:00:00Z',
  62. '2021-12-02T04:15:00Z',
  63. '2021-12-02T04:30:00Z',
  64. '2021-12-02T04:45:00Z',
  65. '2021-12-02T05:00:00Z',
  66. '2021-12-02T05:15:00Z',
  67. '2021-12-02T05:30:00Z',
  68. '2021-12-02T05:45:00Z',
  69. '2021-12-02T06:00:00Z',
  70. '2021-12-02T06:15:00Z',
  71. '2021-12-02T06:30:00Z',
  72. '2021-12-02T06:45:00Z',
  73. '2021-12-02T07:00:00Z',
  74. '2021-12-02T07:15:00Z',
  75. '2021-12-02T07:30:00Z',
  76. '2021-12-02T07:45:00Z',
  77. '2021-12-02T08:00:00Z',
  78. '2021-12-02T08:15:00Z',
  79. '2021-12-02T08:30:00Z',
  80. '2021-12-02T08:45:00Z',
  81. '2021-12-02T09:00:00Z',
  82. '2021-12-02T09:15:00Z',
  83. '2021-12-02T09:30:00Z',
  84. '2021-12-02T09:45:00Z',
  85. '2021-12-02T10:00:00Z',
  86. '2021-12-02T10:15:00Z',
  87. '2021-12-02T10:30:00Z',
  88. '2021-12-02T10:45:00Z',
  89. '2021-12-02T11:00:00Z',
  90. '2021-12-02T11:15:00Z',
  91. '2021-12-02T11:30:00Z',
  92. '2021-12-02T11:45:00Z',
  93. '2021-12-02T12:00:00Z',
  94. '2021-12-02T12:15:00Z',
  95. '2021-12-02T12:30:00Z',
  96. '2021-12-02T12:45:00Z',
  97. '2021-12-02T13:00:00Z',
  98. '2021-12-02T13:15:00Z',
  99. '2021-12-02T13:30:00Z',
  100. '2021-12-02T13:45:00Z',
  101. '2021-12-02T14:00:00Z',
  102. '2021-12-02T14:15:00Z',
  103. '2021-12-02T14:30:00Z',
  104. '2021-12-02T14:45:00Z',
  105. '2021-12-02T15:00:00Z',
  106. '2021-12-02T15:15:00Z',
  107. '2021-12-02T15:30:00Z',
  108. '2021-12-02T15:45:00Z',
  109. '2021-12-02T16:00:00Z',
  110. ],
  111. groups: [
  112. {
  113. by: {},
  114. totals: {
  115. [field]: 51292.95404741901,
  116. },
  117. series: {
  118. [field]: [
  119. 443.6200417187068, 471.7512262596214, 632.5356294251225, 538.6063865509535,
  120. 524.4706847412767, 552.1308328866158, 491.4847951529728, 540.5649544109818,
  121. 430.31622543090765, 513.2803858330382, 498.20598088568426, 503.9482408241235,
  122. 496.3081254057422, 530.4951893480746, 510.9472734431329, 534.2121619563322,
  123. 580.24191602519, 582.2308981360263, 628.6978339387008, 569.093042423482,
  124. 625.5703758567254, 529.286046746119, 491.3038256504387, 548.2822063955006,
  125. 569.3739373104116, 579.5492159758986, 483.9070230718182, 529.9636517032774,
  126. 554.3095224302028, 546.8567462459974, 574.3167313021837, 578.9293435905665,
  127. 561.8965496805288, 576.137674866579, 529.6122522035633, 513.9424504410429,
  128. 543.8130703563698, 597.6542214420452, 510.1568375049254, 510.7187029189223,
  129. 433.78137928589973, 539.3227194785493, 436.44338223053234, 607.1985174516628,
  130. 524.8753880194068, 501.7107697990002, 514.0727518760925, 541.2173843758375,
  131. 556.0898842681038, 535.6274044037233, 475.75355633285346, 587.3256393771101,
  132. 494.61335151920775, 643.5242484747213, 519.9786827806394, 534.7536939750254,
  133. 570.1995703475561, 452.91363051761834, 613.7709480932585, 520.9545797679832,
  134. 497.2156651159481, 625.7054147147829, 490.6365344675922, 592.1175307910397,
  135. 564.6276355603038, 514.8572640893523, 484.47902185133046, 597.7622625233755,
  136. 559.1799635501319, 571.7109630540343, 513.212778566814, 549.1636248727518,
  137. 462.32331107946504, 551.0869305265527, 576.872028698758, 636.4899532813711,
  138. 479.0486254908533, 543.761081985735, 488.9454132823779, 536.1309059508741,
  139. 534.9354940989901, 567.6136279473333, 458.8870965420118, 514.9547377042924,
  140. 525.3278756572803, 502.05863531061544, 575.8454944963837, 524.476069016465,
  141. 431.1190903001866, 543.5139624946099, 598.8881832598959, 510.5100592771207,
  142. 541.151976697214, 550.0881388522994, 485.26355742991586, 460.14344601636975,
  143. ],
  144. },
  145. },
  146. ],
  147. ...params,
  148. };
  149. }
  150. export function MetricsTotalCountByReleaseIn24h(): MetricsApiResponse {
  151. return {
  152. start: '2021-12-01T16:15:00Z',
  153. end: '2021-12-02T16:15:00Z',
  154. query:
  155. 'release:7a82c130be9143361f20bc77252df783cf91e4fc OR release:e102abb2c46e7fe8686441091005c12aed90da99',
  156. meta: [],
  157. intervals: [
  158. '2021-03-17T10:00:00Z',
  159. '2021-03-17T11:00:00Z',
  160. '2021-03-17T12:00:00Z',
  161. '2021-03-17T13:00:00Z',
  162. '2021-03-17T14:00:00Z',
  163. '2021-03-17T15:00:00Z',
  164. '2021-03-17T16:00:00Z',
  165. '2021-03-17T17:00:00Z',
  166. '2021-03-17T18:00:00Z',
  167. '2021-03-17T19:00:00Z',
  168. '2021-03-17T20:00:00Z',
  169. '2021-03-17T21:00:00Z',
  170. '2021-03-17T22:00:00Z',
  171. '2021-03-17T23:00:00Z',
  172. '2021-03-18T00:00:00Z',
  173. '2021-03-18T01:00:00Z',
  174. '2021-03-18T02:00:00Z',
  175. '2021-03-18T03:00:00Z',
  176. '2021-03-18T04:00:00Z',
  177. '2021-03-18T05:00:00Z',
  178. '2021-03-18T06:00:00Z',
  179. '2021-03-18T07:00:00Z',
  180. '2021-03-18T08:00:00Z',
  181. '2021-03-18T09:00:00Z',
  182. ],
  183. groups: [
  184. {
  185. by: {project: '123', release: '7a82c130be9143361f20bc77252df783cf91e4fc'},
  186. totals: {'sum(session)': 219826},
  187. series: {
  188. 'sum(session)': [
  189. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3444, 14912, 15649, 18019, 16726,
  190. 17540, 16970, 25015, 34686, 46434, 10431,
  191. ],
  192. },
  193. },
  194. {
  195. by: {release: 'e102abb2c46e7fe8686441091005c12aed90da99', project: '123'},
  196. totals: {'sum(session)': 6320},
  197. series: {
  198. 'sum(session)': [
  199. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5809, 400, 22, 26, 12, 19, 8, 0, 19, 5,
  200. 0,
  201. ],
  202. },
  203. },
  204. ],
  205. };
  206. }
  207. export function MetricsSessionUserCountByStatusByRelease(): MetricsApiResponse {
  208. return {
  209. start: '2022-01-15T00:00:00Z',
  210. end: '2022-01-29T00:00:00Z',
  211. query: '',
  212. meta: [],
  213. intervals: [
  214. '2022-01-15T00:00:00Z',
  215. '2022-01-16T00:00:00Z',
  216. '2022-01-17T00:00:00Z',
  217. '2022-01-18T00:00:00Z',
  218. '2022-01-19T00:00:00Z',
  219. '2022-01-20T00:00:00Z',
  220. '2022-01-21T00:00:00Z',
  221. '2022-01-22T00:00:00Z',
  222. '2022-01-23T00:00:00Z',
  223. '2022-01-24T00:00:00Z',
  224. '2022-01-25T00:00:00Z',
  225. '2022-01-26T00:00:00Z',
  226. '2022-01-27T00:00:00Z',
  227. '2022-01-28T00:00:00Z',
  228. ],
  229. groups: [
  230. {
  231. by: {'session.status': 'crashed', release: '1'},
  232. totals: {
  233. 'sum(sentry.sessions.session)': 34,
  234. 'count_unique(sentry.sessions.user)': 1,
  235. },
  236. series: {
  237. 'sum(sentry.sessions.session)': [0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 11, 0, 0, 0],
  238. 'count_unique(sentry.sessions.user)': [
  239. 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
  240. ],
  241. },
  242. },
  243. {
  244. by: {'session.status': 'abnormal', release: '1'},
  245. totals: {
  246. 'sum(sentry.sessions.session)': 1,
  247. 'count_unique(sentry.sessions.user)': 1,
  248. },
  249. series: {
  250. 'sum(sentry.sessions.session)': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  251. 'count_unique(sentry.sessions.user)': [
  252. 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  253. ],
  254. },
  255. },
  256. {
  257. by: {'session.status': 'errored', release: '1'},
  258. totals: {
  259. 'sum(sentry.sessions.session)': 451,
  260. 'count_unique(sentry.sessions.user)': 2,
  261. },
  262. series: {
  263. 'sum(sentry.sessions.session)': [0, 0, 0, 0, 0, 37, 0, 0, 0, 335, 79, 0, 0, 0],
  264. 'count_unique(sentry.sessions.user)': [
  265. 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 2, 0, 0, 0,
  266. ],
  267. },
  268. },
  269. {
  270. by: {'session.status': 'healthy', release: '1'},
  271. totals: {
  272. 'sum(sentry.sessions.session)': 5058,
  273. 'count_unique(sentry.sessions.user)': 3,
  274. },
  275. series: {
  276. 'sum(sentry.sessions.session)': [
  277. 0, 0, 0, 0, 0, 2503, 661, 0, 0, 1464, 430, 0, 0, 0,
  278. ],
  279. 'count_unique(sentry.sessions.user)': [
  280. 0, 0, 0, 0, 0, 3, 3, 0, 0, 1, 1, 0, 0, 0,
  281. ],
  282. },
  283. },
  284. {
  285. by: {'session.status': 'crashed', release: '2'},
  286. totals: {
  287. 'sum(sentry.sessions.session)': 35,
  288. 'count_unique(sentry.sessions.user)': 2,
  289. },
  290. series: {
  291. 'sum(sentry.sessions.session)': [1, 0, 0, 0, 0, 0, 0, 0, 0, 23, 11, 0, 0, 0],
  292. 'count_unique(sentry.sessions.user)': [
  293. 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0,
  294. ],
  295. },
  296. },
  297. {
  298. by: {'session.status': 'abnormal', release: '2'},
  299. totals: {
  300. 'sum(sentry.sessions.session)': 1,
  301. 'count_unique(sentry.sessions.user)': 1,
  302. },
  303. series: {
  304. 'sum(sentry.sessions.session)': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  305. 'count_unique(sentry.sessions.user)': [
  306. 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  307. ],
  308. },
  309. },
  310. {
  311. by: {'session.status': 'errored', release: '2'},
  312. totals: {
  313. 'sum(sentry.sessions.session)': 452,
  314. 'count_unique(sentry.sessions.user)': 1,
  315. },
  316. series: {
  317. 'sum(sentry.sessions.session)': [1, 0, 0, 0, 0, 37, 0, 0, 0, 335, 79, 0, 0, 0],
  318. 'count_unique(sentry.sessions.user)': [
  319. 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0,
  320. ],
  321. },
  322. },
  323. {
  324. by: {'session.status': 'healthy', release: '2'},
  325. totals: {
  326. 'sum(sentry.sessions.session)': 5059,
  327. 'count_unique(sentry.sessions.user)': 10,
  328. },
  329. series: {
  330. 'sum(sentry.sessions.session)': [
  331. 1, 0, 0, 0, 0, 2503, 661, 0, 0, 1464, 430, 0, 0, 0,
  332. ],
  333. 'count_unique(sentry.sessions.user)': [
  334. 1, 0, 0, 0, 0, 10, 3, 0, 0, 4, 3, 0, 0, 0,
  335. ],
  336. },
  337. },
  338. ],
  339. };
  340. }