metrics.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. // The last entry in meta has a different shape
  58. | {
  59. group_bys: string[];
  60. limit: number | null;
  61. order: string | null;
  62. scaling_factor?: number | null;
  63. unit?: string | null;
  64. unit_family?: 'duration' | 'information' | null;
  65. }
  66. )[][];
  67. start: string;
  68. }
  69. export type MetricsGroup = {
  70. by: Record<string, string>;
  71. series: Record<string, Array<number | null>>;
  72. totals: Record<string, number | null>;
  73. };
  74. export type MetricsTagCollection = Record<string, MetricsTag>;
  75. export type MetricsTag = {
  76. key: string;
  77. };
  78. export type MetricsTagValue = {
  79. key: string;
  80. value: string;
  81. };
  82. export type MetricMeta = {
  83. blockingStatus: BlockingStatus[];
  84. mri: MRI;
  85. // name is returned by the API but should not be used, use parseMRI(mri).name instead
  86. // name: string;
  87. operations: MetricsOperation[];
  88. projectIds: number[];
  89. type: MetricType;
  90. unit: string;
  91. };
  92. export type BlockingStatus = {
  93. blockedTags: string[];
  94. isBlocked: boolean;
  95. projectId: number;
  96. };
  97. export type MetricsMetaCollection = Record<string, MetricMeta>;