metrics.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. };
  38. export type MetricsApiRequestQueryOptions = MetricsApiRequestQuery & {
  39. fidelity?: 'high' | 'low';
  40. useNewMetricsLayer?: boolean;
  41. };
  42. export type MetricsApiResponse = {
  43. end: string;
  44. groups: MetricsGroup[];
  45. intervals: string[];
  46. meta: MetricMeta[];
  47. query: string;
  48. start: string;
  49. };
  50. export type MetricsGroup = {
  51. by: Record<string, string>;
  52. series: Record<string, Array<number | null>>;
  53. totals: Record<string, number | null>;
  54. };
  55. export type MetricsTagCollection = Record<string, MetricsTag>;
  56. export type MetricsTag = {
  57. key: string;
  58. };
  59. export type MetricsTagValue = {
  60. key: string;
  61. value: string;
  62. };
  63. export type MetricMeta = {
  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 MetricsMetaCollection = Record<string, MetricMeta>;