@@ -7,27 +7,19 @@ use relay_general::protocol::Event;
77use relay_sampling:: {
88 pseudo_random_from_uuid, DynamicSamplingContext , RuleId , SamplingConfig , SamplingRule ,
99} ;
10- use relay_statsd:: metric;
1110
1211use crate :: actors:: project:: ProjectState ;
1312use crate :: envelope:: { Envelope , ItemType } ;
14- use crate :: statsd:: { RelayCounters , RelayTimers } ;
1513
16- macro_rules! some_or {
17- ( $e: expr, $fallback : expr ) => {
14+ macro_rules! or_ok_none {
15+ ( $e: expr) => {
1816 match $e {
1917 Some ( x) => x,
20- None => $fallback ,
18+ None => return Ok ( None ) ,
2119 }
2220 } ;
2321}
2422
25- macro_rules! or_ok_none {
26- ( $e: expr) => {
27- some_or!( $e, return Ok ( None ) )
28- } ;
29- }
30-
3123/// The result of a sampling operation.
3224#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
3325pub enum SamplingResult {
@@ -133,32 +125,6 @@ pub fn should_keep_event(
133125 SamplingResult :: Keep
134126}
135127
136- fn track_sampling_metrics (
137- sampling_context : Option < & DynamicSamplingContext > ,
138- event : Option < & Event > ,
139- project_state : & ProjectState ,
140- sampling_project_state : Option < & ProjectState > ,
141- ) {
142- let sampling_context = some_or ! ( sampling_context, return ) ;
143- let event = some_or ! ( event, return ) ;
144- let sampling_project_state = some_or ! ( sampling_project_state, return ) ;
145-
146- if sampling_project_state. project_id != project_state. project_id {
147- return ;
148- }
149-
150- let is_unstable_transaction_name = event. transaction . value ( ) != sampling_context. transaction ;
151- let dsc_has_transaction_name = sampling_context. transaction . is_some ( ) ;
152- let event_has_transaction_name = event. transaction . value ( ) . is_some ( ) ;
153-
154- metric ! (
155- counter( RelayCounters :: DynamicSamplingRootTransaction ) += 1 ,
156- is_unstable_transaction_name = is_unstable_transaction_name,
157- dsc_has_transaction_name = dsc_has_transaction_name,
158- event_has_transaction_name = event_has_transaction_name,
159- ) ;
160- }
161-
162128/// Returns the project key defined in the `trace` header of the envelope, if defined.
163129/// If there are no transactions in the envelope, we return None here, because there is nothing
164130/// to sample by trace.
0 commit comments