metrics.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. {group_bys: string[]; limit: number | null; order: string | null},
  58. ][];
  59. start: string;
  60. }
  61. export type MetricsGroup = {
  62. by: Record<string, string>;
  63. series: Record<string, Array<number | null>>;
  64. totals: Record<string, number | null>;
  65. };
  66. export type MetricsTagCollection = Record<string, MetricsTag>;
  67. export type MetricsTag = {
  68. key: string;
  69. };
  70. export type MetricsTagValue = {
  71. key: string;
  72. value: string;
  73. };
  74. export type MetricMeta = {
  75. blockingStatus: BlockingStatus[];
  76. mri: MRI;
  77. // name is returned by the API but should not be used, use parseMRI(mri).name instead
  78. // name: string;
  79. operations: MetricsOperation[];
  80. type: MetricType;
  81. unit: string;
  82. };
  83. export type BlockingStatus = {
  84. blockedTags: string[];
  85. isBlocked: boolean;
  86. projectId: number;
  87. };
  88. export type MetricsMetaCollection = Record<string, MetricMeta>;