isInsightsMetricAlert.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {parseField} from 'sentry/utils/metrics/mri';
  2. export const INSIGHTS_METRICS_OPERATIONS_WITHOUT_ARGS = [
  3. {
  4. label: 'spm',
  5. value: 'spm',
  6. mri: 'd:spans/duration@millisecond',
  7. },
  8. {
  9. label: 'cache_miss_rate',
  10. value: 'cache_miss_rate',
  11. mri: 'd:spans/duration@millisecond',
  12. },
  13. ];
  14. export const INSIGHTS_METRICS_OPERATIONS_WITH_CUSTOM_ARGS = [
  15. {
  16. label: 'http_response_rate',
  17. value: 'http_response_rate',
  18. options: [
  19. {label: '3', value: '3'},
  20. {label: '4', value: '4'},
  21. {label: '5', value: '5'},
  22. ],
  23. mri: 'd:spans/duration@millisecond',
  24. },
  25. {
  26. label: 'performance_score',
  27. value: 'performance_score',
  28. options: [
  29. {label: 'measurements.score.lcp', value: 'measurements.score.lcp'},
  30. {label: 'measurements.score.fcp', value: 'measurements.score.fcp'},
  31. {label: 'measurements.score.inp', value: 'measurements.score.inp'},
  32. {label: 'measurements.score.cls', value: 'measurements.score.cls'},
  33. {label: 'measurements.score.ttfb', value: 'measurements.score.ttfb'},
  34. {label: 'measurements.score.total', value: 'measurements.score.total'},
  35. ],
  36. mri: 'd:transactions/measurements.score.total@ratio',
  37. },
  38. ];
  39. export const INSIGHTS_METRICS_OPERATIONS = [
  40. ...INSIGHTS_METRICS_OPERATIONS_WITH_CUSTOM_ARGS,
  41. ...INSIGHTS_METRICS_OPERATIONS_WITHOUT_ARGS,
  42. ];
  43. export const INSIGHTS_METRICS = [
  44. 'd:spans/webvital.inp@millisecond',
  45. 'd:spans/duration@millisecond',
  46. 'd:spans/exclusive_time@millisecond',
  47. 'd:spans/http.response_content_length@byte',
  48. 'd:spans/http.decoded_response_content_length@byte',
  49. 'd:spans/http.response_transfer_size@byte',
  50. 'd:spans/cache.item_size@byte',
  51. 'g:spans/messaging.message.receive.latency@millisecond',
  52. 'g:spans/mobile.frames_delay@second',
  53. 'g:spans/mobile.total_frames@none',
  54. 'g:spans/mobile.frozen_frames@none',
  55. 'g:spans/mobile.slow_frames@none',
  56. 'c:spans/ai.total_tokens.used@none',
  57. 'c:spans/ai.total_cost@usd',
  58. 'd:transactions/measurements.score.lcp@ratio',
  59. 'd:transactions/measurements.score.fcp@ratio',
  60. 'd:transactions/measurements.score.cls@ratio',
  61. 'd:transactions/measurements.score.ttfb@ratio',
  62. 'd:transactions/measurements.score.inp@ratio',
  63. 'd:transactions/measurements.score.total@ratio',
  64. ];
  65. export const isInsightsMetricAlert = (aggregate: string) => {
  66. const {mri, aggregation} = parseField(aggregate) ?? {};
  67. if (
  68. INSIGHTS_METRICS.includes(mri as string) ||
  69. INSIGHTS_METRICS_OPERATIONS.map(({value}) => value).includes(aggregation as string)
  70. ) {
  71. return true;
  72. }
  73. return false;
  74. };