metrics.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. mri: MRI;
  64. // name is returned by the API but should not be used, use parseMRI(mri).name instead
  65. // name: string;
  66. operations: MetricsOperation[];
  67. type: MetricType;
  68. unit: string;
  69. };
  70. export type MetricsMetaCollection = Record<string, MetricMeta>;