metrics.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import {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. query: string;
  24. groupBy?: string[];
  25. };
  26. export type MetricsApiRequestQuery = MetricsApiRequestMetric & {
  27. interval: string;
  28. end?: DateString;
  29. environment?: string[];
  30. includeSeries?: number;
  31. includeTotals?: number;
  32. orderBy?: string;
  33. per_page?: number;
  34. project?: number[];
  35. start?: DateString;
  36. statsPeriod?: string;
  37. useNewMetricsLayer?: boolean;
  38. };
  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 type MetricsGroup = {
  48. by: Record<string, string>;
  49. series: Record<string, Array<number | null>>;
  50. totals: Record<string, number | null>;
  51. };
  52. export type MetricsTagCollection = Record<string, MetricsTag>;
  53. export type MetricsTag = {
  54. key: string;
  55. };
  56. export type MetricsTagValue = {
  57. key: string;
  58. value: string;
  59. };
  60. export type MetricMeta = {
  61. mri: MRI;
  62. // name is returned by the API but should not be used, use parseMRI(mri).name instead
  63. // name: string;
  64. operations: MetricsOperation[];
  65. type: MetricType;
  66. unit: string;
  67. };
  68. export type MetricsMetaCollection = Record<string, MetricMeta>;