metrics.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 interface MetricsApiRequestQueryOptions extends Partial<MetricsApiRequestQuery> {
  40. intervalLadder?: MetricsDataIntervalLadder;
  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. blockingStatus: BlockingStatus[];
  65. mri: MRI;
  66. // name is returned by the API but should not be used, use parseMRI(mri).name instead
  67. // name: string;
  68. operations: MetricsOperation[];
  69. type: MetricType;
  70. unit: string;
  71. };
  72. export type BlockingStatus = {
  73. blockedTags: string[];
  74. isBlocked: boolean;
  75. projectId: number;
  76. };
  77. export type MetricsMetaCollection = Record<string, MetricMeta>;