metrics.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import type {DateString} from 'sentry/types/core';
  2. export type MetricsOperation =
  3. | 'sum'
  4. | 'count_unique'
  5. | 'avg'
  6. | 'count'
  7. | 'max'
  8. | 'p50'
  9. | 'p75'
  10. | 'p95'
  11. | 'p99';
  12. export type MetricType = 'c' | 'd' | 'g' | 'e' | 's';
  13. export type UseCase = 'custom' | 'transactions' | 'sessions' | 'spans';
  14. export type MRI = `${MetricType}:${UseCase}${string}@${string}`;
  15. export type ParsedMRI = {
  16. name: string;
  17. type: MetricType;
  18. unit: string;
  19. useCase: UseCase;
  20. };
  21. export type MetricsApiRequestMetric = {
  22. field: string;
  23. groupBy?: string[];
  24. orderBy?: string;
  25. query?: string;
  26. };
  27. export interface MetricsApiRequestQuery extends MetricsApiRequestMetric {
  28. interval: string;
  29. end?: DateString;
  30. environment?: string[];
  31. includeSeries?: number;
  32. includeTotals?: number;
  33. limit?: number;
  34. project?: number[];
  35. start?: DateString;
  36. statsPeriod?: string;
  37. }
  38. export type MetricsDataIntervalLadder = 'ddm' | 'bar' | 'dashboard';
  39. export type MetricsApiResponse = {
  40. end: string;
  41. groups: MetricsGroup[];
  42. intervals: string[];
  43. meta: MetricMeta[];
  44. query: string;
  45. start: string;
  46. };
  47. export interface MetricsQueryApiResponse {
  48. data: {
  49. by: Record<string, string>;
  50. series: Array<number | null>;
  51. totals: number;
  52. }[][];
  53. end: string;
  54. intervals: string[];
  55. meta: [
  56. {name: string; type: string},
  57. {
  58. group_bys: string[];
  59. limit: number | null;
  60. order: string | null;
  61. scaling_factor?: number | null;
  62. unit?: string | null;
  63. unit_family?: 'duration' | 'information' | null;
  64. },
  65. ][];
  66. start: string;
  67. }
  68. export type MetricsGroup = {
  69. by: Record<string, string>;
  70. series: Record<string, Array<number | null>>;
  71. totals: Record<string, number | null>;
  72. };
  73. export type MetricsTagCollection = Record<string, MetricsTag>;
  74. export type MetricsTag = {
  75. key: string;
  76. };
  77. export type MetricsTagValue = {
  78. key: string;
  79. value: string;
  80. };
  81. export type MetricMeta = {
  82. blockingStatus: BlockingStatus[];
  83. mri: MRI;
  84. // name is returned by the API but should not be used, use parseMRI(mri).name instead
  85. // name: string;
  86. operations: MetricsOperation[];
  87. type: MetricType;
  88. unit: string;
  89. };
  90. export type BlockingStatus = {
  91. blockedTags: string[];
  92. isBlocked: boolean;
  93. projectId: number;
  94. };
  95. export type MetricsMetaCollection = Record<string, MetricMeta>;