sampling.tsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. export enum SamplingRuleType {
  2. /**
  3. * The rule applies to traces (transaction events considered in the context of a trace)
  4. */
  5. TRACE = 'trace',
  6. /**
  7. * The rule applies to transaction events considered independently
  8. */
  9. TRANSACTION = 'transaction',
  10. }
  11. export enum SamplingConditionOperator {
  12. /**
  13. * Combine multiple sub-conditions with the operator 'and'
  14. */
  15. AND = 'and',
  16. }
  17. export enum SamplingRuleOperator {
  18. /**
  19. * The first rule on the list
  20. */
  21. IF = 'if',
  22. /**
  23. * All other rules, except rules without a condition
  24. */
  25. ELSE_IF = 'else_if',
  26. /**
  27. * Rules without a condition. In this case the rule cannot be reordered and is “pinned” at the bottom of the list
  28. */
  29. ELSE = 'else',
  30. }
  31. export enum SamplingInnerOperator {
  32. /**
  33. * It uses glob matches for checking (e.g. releases use glob matching "1.1.*" will match release 1.1.1 and 1.1.2)
  34. */
  35. GLOB_MATCH = 'glob',
  36. /**
  37. * It uses simple equality for checking
  38. */
  39. EQUAL = 'eq',
  40. /**
  41. * Custom Operation
  42. */
  43. CUSTOM = 'custom',
  44. }
  45. /**
  46. * String of the sampling category that's used on the backend.
  47. * Default naming strategy should be based on the path in the event, prefixed with `event.`.
  48. * To see the path in the event, click on the JSON button on the issue details page.
  49. */
  50. export enum SamplingInnerName {
  51. TRACE_RELEASE = 'trace.release',
  52. TRACE_ENVIRONMENT = 'trace.environment',
  53. TRACE_USER_ID = 'trace.user.id',
  54. TRACE_USER_SEGMENT = 'trace.user.segment',
  55. TRACE_TRANSACTION = 'trace.transaction',
  56. EVENT_RELEASE = 'event.release',
  57. EVENT_ENVIRONMENT = 'event.environment',
  58. EVENT_USER_ID = 'event.user.id',
  59. EVENT_USER_SEGMENT = 'event.user.segment',
  60. EVENT_LOCALHOST = 'event.is_local_ip',
  61. EVENT_WEB_CRAWLERS = 'event.web_crawlers',
  62. EVENT_BROWSER_EXTENSIONS = 'event.has_bad_browser_extensions',
  63. EVENT_TRANSACTION = 'event.transaction',
  64. EVENT_OS_NAME = 'event.contexts.os.name',
  65. EVENT_OS_VERSION = 'event.contexts.os.version',
  66. EVENT_DEVICE_NAME = 'event.contexts.device.name',
  67. EVENT_DEVICE_FAMILY = 'event.contexts.device.family',
  68. // Custom operators
  69. EVENT_IP_ADDRESSES = 'event.client_ip',
  70. EVENT_LEGACY_BROWSER = 'event.legacy_browser',
  71. EVENT_ERROR_MESSAGES = 'event.error_messages',
  72. EVENT_CSP = 'event.csp',
  73. EVENT_CUSTOM_TAG = 'event.custom_tag', // used for the fresh new custom tag condition (gets replaced once you choose tag key)
  74. }
  75. export enum LegacyBrowser {
  76. IE_PRE_9 = 'ie_pre_9',
  77. IE9 = 'ie9',
  78. IE10 = 'ie10',
  79. IE11 = 'ie11',
  80. SAFARI_PRE_6 = 'safari_pre_6',
  81. OPERA_PRE_15 = 'opera_pre_15',
  82. OPERA_MINI_PRE_8 = 'opera_mini_pre_8',
  83. ANDROID_PRE_4 = 'android_pre_4',
  84. }
  85. type SamplingConditionLogicalInnerGlob = {
  86. name:
  87. | SamplingInnerName.EVENT_RELEASE
  88. | SamplingInnerName.TRACE_RELEASE
  89. | SamplingInnerName.EVENT_TRANSACTION
  90. | SamplingInnerName.TRACE_TRANSACTION
  91. | SamplingInnerName.EVENT_OS_NAME
  92. | SamplingInnerName.EVENT_OS_VERSION
  93. | SamplingInnerName.EVENT_DEVICE_FAMILY
  94. | SamplingInnerName.EVENT_DEVICE_NAME
  95. | SamplingInnerName.EVENT_CUSTOM_TAG
  96. | string; // for custom tags
  97. op: SamplingInnerOperator.GLOB_MATCH;
  98. value: Array<string>;
  99. };
  100. type SamplingConditionLogicalInnerEq = {
  101. name:
  102. | SamplingInnerName.EVENT_ENVIRONMENT
  103. | SamplingInnerName.TRACE_ENVIRONMENT
  104. | SamplingInnerName.EVENT_USER_ID
  105. | SamplingInnerName.TRACE_USER_ID
  106. | SamplingInnerName.EVENT_USER_SEGMENT
  107. | SamplingInnerName.TRACE_USER_SEGMENT;
  108. op: SamplingInnerOperator.EQUAL;
  109. options: {
  110. ignoreCase: boolean;
  111. };
  112. value: Array<string>;
  113. };
  114. type SamplingConditionLogicalInnerEqBoolean = {
  115. name:
  116. | SamplingInnerName.EVENT_BROWSER_EXTENSIONS
  117. | SamplingInnerName.EVENT_LOCALHOST
  118. | SamplingInnerName.EVENT_WEB_CRAWLERS;
  119. op: SamplingInnerOperator.EQUAL;
  120. value: boolean;
  121. };
  122. type SamplingConditionLogicalInnerCustom = {
  123. name:
  124. | SamplingInnerName.EVENT_CSP
  125. | SamplingInnerName.EVENT_ERROR_MESSAGES
  126. | SamplingInnerName.EVENT_IP_ADDRESSES;
  127. op: SamplingInnerOperator.CUSTOM;
  128. value: Array<string>;
  129. };
  130. type SamplingConditionLogicalInnerCustomLegacyBrowser = {
  131. name: SamplingInnerName.EVENT_LEGACY_BROWSER;
  132. op: SamplingInnerOperator.CUSTOM;
  133. value: Array<LegacyBrowser>;
  134. };
  135. export type SamplingConditionLogicalInner =
  136. | SamplingConditionLogicalInnerGlob
  137. | SamplingConditionLogicalInnerEq
  138. | SamplingConditionLogicalInnerEqBoolean
  139. | SamplingConditionLogicalInnerCustom
  140. | SamplingConditionLogicalInnerCustomLegacyBrowser;
  141. export type SamplingCondition = {
  142. inner: Array<SamplingConditionLogicalInner>;
  143. op: SamplingConditionOperator.AND;
  144. };
  145. export type SamplingRule = {
  146. /**
  147. * It is a possibly empty list of conditions to which the rule applies.
  148. * The conditions are combined using the and operator (so all the conditions must be satisfied for the rule to apply).
  149. * If the conditions field is an empty list the rule applies for all events that satisfy the projectIds and the ty fields.
  150. */
  151. condition: SamplingCondition;
  152. /**
  153. * This is a unique number within a project
  154. */
  155. id: number;
  156. /**
  157. * It is the sampling rate that will be applied if the rule is selected
  158. */
  159. sampleRate: number;
  160. /**
  161. * Describes the type of rule
  162. */
  163. type: SamplingRuleType;
  164. /**
  165. * A rule can be disabled if it doesn't contain a condition (Else case)
  166. */
  167. disabled?: boolean;
  168. };
  169. export type SamplingRules = Array<SamplingRule>;