sampling.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import {Project} from './project';
  2. export enum SamplingRuleType {
  3. /**
  4. * The rule applies to traces (transaction events considered in the context of a trace)
  5. */
  6. TRACE = 'trace',
  7. }
  8. export enum SamplingConditionOperator {
  9. /**
  10. * Combine multiple sub-conditions with the operator 'and'
  11. */
  12. AND = 'and',
  13. }
  14. export enum SamplingRuleOperator {
  15. /**
  16. * The first rule on the list
  17. */
  18. IF = 'if',
  19. /**
  20. * All other rules, except rules without a condition
  21. */
  22. ELSE_IF = 'else_if',
  23. /**
  24. * Rules without a condition. In this case the rule cannot be reordered and is “pinned” at the bottom of the list
  25. */
  26. ELSE = 'else',
  27. }
  28. export enum SamplingInnerOperator {
  29. /**
  30. * It uses glob matches for checking (e.g. releases use glob matching "1.1.*" will match release 1.1.1 and 1.1.2)
  31. */
  32. GLOB_MATCH = 'glob',
  33. /**
  34. * It uses simple equality for checking
  35. */
  36. EQUAL = 'eq',
  37. }
  38. /**
  39. * String of the sampling category that's used on the backend.
  40. * Default naming strategy should be based on the path in the event, prefixed with `event.`.
  41. * To see the path in the event, click on the JSON button on the issue details page.
  42. */
  43. export enum SamplingInnerName {
  44. TRACE_RELEASE = 'trace.release',
  45. TRACE_ENVIRONMENT = 'trace.environment',
  46. }
  47. type SamplingConditionLogicalInnerGlob = {
  48. name: SamplingInnerName.TRACE_RELEASE;
  49. op: SamplingInnerOperator.GLOB_MATCH;
  50. value: Array<string>;
  51. };
  52. type SamplingConditionLogicalInnerEq = {
  53. name: SamplingInnerName.TRACE_ENVIRONMENT;
  54. op: SamplingInnerOperator.EQUAL;
  55. options: {
  56. ignoreCase: boolean;
  57. };
  58. value: Array<string>;
  59. };
  60. export type SamplingConditionLogicalInner =
  61. | SamplingConditionLogicalInnerGlob
  62. | SamplingConditionLogicalInnerEq;
  63. export type SamplingCondition = {
  64. inner: Array<SamplingConditionLogicalInner>;
  65. op: SamplingConditionOperator.AND;
  66. };
  67. export type SamplingRule = {
  68. /**
  69. * It is a possibly empty list of conditions to which the rule applies.
  70. * The conditions are combined using the and operator (so all the conditions must be satisfied for the rule to apply).
  71. * If the conditions field is an empty list the rule applies for all events that satisfy the projectIds and the ty fields.
  72. */
  73. condition: SamplingCondition;
  74. /**
  75. * This is a unique number within a project
  76. */
  77. id: number;
  78. /**
  79. * It is the sampling rate that will be applied if the rule is selected
  80. */
  81. sampleRate: number;
  82. /**
  83. * Describes the type of rule
  84. */
  85. type: SamplingRuleType;
  86. /**
  87. * Indicates if the rule is enabled for server-side sampling
  88. */
  89. active?: boolean;
  90. };
  91. export type SamplingDistribution = {
  92. endTimestamp: string | null;
  93. null_sample_rate_percentage: null | number;
  94. project_breakdown:
  95. | null
  96. | {
  97. 'count()': number;
  98. project: string;
  99. project_id: number;
  100. }[];
  101. sample_rate_distributions: null | {
  102. avg: null | number;
  103. max: null | number;
  104. min: null | number;
  105. p50: null | number;
  106. p90: null | number;
  107. p95: null | number;
  108. p99: null | number;
  109. };
  110. sample_size: number;
  111. startTimestamp: string | null;
  112. };
  113. export type SamplingSdkVersion = {
  114. isSendingSampleRate: boolean;
  115. isSendingSource: boolean;
  116. isSupportedPlatform: boolean;
  117. latestSDKName: string;
  118. latestSDKVersion: string;
  119. project: string;
  120. };
  121. export type RecommendedSdkUpgrade = {
  122. latestSDKName: SamplingSdkVersion['latestSDKName'];
  123. latestSDKVersion: SamplingSdkVersion['latestSDKVersion'];
  124. project: Project;
  125. };
  126. export type UniformModalsSubmit = (props: {
  127. sampleRate: number;
  128. uniformRateModalOrigin: boolean;
  129. onError?: () => void;
  130. onSuccess?: (newRules: SamplingRule[]) => void;
  131. recommendedSampleRate?: boolean;
  132. rule?: SamplingRule;
  133. }) => void;