metrics.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import type {DateString} from 'sentry/types/core';
  2. export type MetricsAggregate =
  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 = 'metrics' | 'bar' | 'dashboard';
  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 interface MetricsQueryApiResponse {
  48. data: {
  49. by: Record<string, string>;
  50. series: Array<number | null>;
  51. totals: number;
  52. }[][];
  53. end: string;
  54. intervals: string[];
  55. meta: [
  56. ...{name: string; type: string}[],
  57. // The last entry in meta has a different shape
  58. MetricsQueryApiResponseLastMeta,
  59. ][];
  60. start: string;
  61. }
  62. export interface MetricsQueryApiResponseLastMeta {
  63. group_bys: string[];
  64. limit: number | null;
  65. order: string | null;
  66. has_more?: boolean;
  67. scaling_factor?: number | null;
  68. unit?: string | null;
  69. unit_family?: 'duration' | 'information' | null;
  70. }
  71. export type MetricsGroup = {
  72. by: Record<string, string>;
  73. series: Record<string, Array<number | null>>;
  74. totals: Record<string, number | null>;
  75. };
  76. export type MetricsTagCollection = Record<string, MetricsTag>;
  77. export type MetricsTag = {
  78. key: string;
  79. };
  80. export type MetricsTagValue = {
  81. key: string;
  82. value: string;
  83. };
  84. export type MetricMeta = {
  85. blockingStatus: BlockingStatus[];
  86. mri: MRI;
  87. // name is returned by the API but should not be used, use parseMRI(mri).name instead
  88. // name: string;
  89. operations: MetricsAggregate[];
  90. projectIds: number[];
  91. type: MetricType;
  92. unit: string;
  93. };
  94. export type BlockingStatus = {
  95. blockedTags: string[];
  96. isBlocked: boolean;
  97. projectId: number;
  98. };
  99. export type MetricsMetaCollection = Record<string, MetricMeta>;