metrics.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 type MetricsApiRequestQuery = 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 MetricsApiRequestQueryOptions = Partial<MetricsApiRequestQuery> & {
  39. fidelity?: 'high' | 'low';
  40. };
  41. export type MetricsApiResponse = {
  42. end: string;
  43. groups: MetricsGroup[];
  44. intervals: string[];
  45. meta: MetricMeta[];
  46. query: string;
  47. start: string;
  48. };
  49. export type MetricsGroup = {
  50. by: Record<string, string>;
  51. series: Record<string, Array<number | null>>;
  52. totals: Record<string, number | null>;
  53. };
  54. export type MetricsTagCollection = Record<string, MetricsTag>;
  55. export type MetricsTag = {
  56. key: string;
  57. };
  58. export type MetricsTagValue = {
  59. key: string;
  60. value: string;
  61. };
  62. export type MetricMeta = {
  63. blockingStatus: BlockingStatus[];
  64. mri: MRI;
  65. // name is returned by the API but should not be used, use parseMRI(mri).name instead
  66. // name: string;
  67. operations: MetricsOperation[];
  68. type: MetricType;
  69. unit: string;
  70. };
  71. export type BlockingStatus = {
  72. blockedTags: string[];
  73. isBlocked: boolean;
  74. projectId: number;
  75. };
  76. export type MetricsMetaCollection = Record<string, MetricMeta>;