sampling.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. parentProjectBreakdown:
  94. | null
  95. | {
  96. percentage: number;
  97. project: string;
  98. projectId: number;
  99. }[];
  100. projectBreakdown:
  101. | null
  102. | {
  103. 'count()': number;
  104. project: string;
  105. projectId: number;
  106. }[];
  107. sampleSize: number;
  108. startTimestamp: string | null;
  109. };
  110. export type SamplingSdkVersion = {
  111. isSendingSampleRate: boolean;
  112. isSendingSource: boolean;
  113. isSupportedPlatform: boolean;
  114. latestSDKName: string;
  115. latestSDKVersion: string;
  116. project: string;
  117. };
  118. export type RecommendedSdkUpgrade = {
  119. latestSDKName: SamplingSdkVersion['latestSDKName'];
  120. latestSDKVersion: SamplingSdkVersion['latestSDKVersion'];
  121. project: Project;
  122. };
  123. export type UniformModalsSubmit = (props: {
  124. sampleRate: number;
  125. uniformRateModalOrigin: boolean;
  126. onError?: () => void;
  127. onSuccess?: (newRules: SamplingRule[]) => void;
  128. recommendedSampleRate?: boolean;
  129. rule?: SamplingRule;
  130. }) => void;
  131. export enum DynamicSamplingBiasType {
  132. BOOST_ENVIRONMENTS = 'boostEnvironments',
  133. BOOST_LATEST_RELEASES = 'boostLatestRelease',
  134. IGNORE_HEALTH_CHECKS = 'ignoreHealthChecks',
  135. }
  136. export type DynamicSamplingBias = {
  137. active: boolean;
  138. id: DynamicSamplingBiasType;
  139. };