@@ -147,16 +147,12 @@ impl FromMessage<Self> for TrackOutcome {
147
147
/// Defines the possible outcomes from processing an event.
148
148
#[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
149
149
pub enum Outcome {
150
- /// The event has been accepted and handled completely.
151
- ///
152
- /// For events and most other types, this is never emitted by Relay as the event
153
- /// may be discarded by the processing pipeline after Relay.
154
- /// Only the `save_event` task in Sentry finally accepts an event.
155
- ///
156
- /// The only data type for which this outcome is emitted by Relay is [`DataCategory::Profile`].
157
- /// (See [`crate::actors::processor::EnvelopeProcessor`])
158
- #[ cfg( feature = "processing" ) ]
159
- Accepted ,
150
+ // /// The event has been accepted and handled completely.
151
+ // ///
152
+ // /// This is never emitted by Relay as the event may be discarded by the processing pipeline
153
+ // /// after Relay. Only the `save_event` task in Sentry finally accepts an event.
154
+ // #[allow(dead_code)]
155
+ // Accepted,
160
156
/// The event has been filtered due to a configured filter.
161
157
Filtered ( FilterStatKey ) ,
162
158
@@ -181,8 +177,6 @@ impl Outcome {
181
177
/// Returns the raw numeric value of this outcome for the JSON and Kafka schema.
182
178
fn to_outcome_id ( & self ) -> OutcomeId {
183
179
match self {
184
- #[ cfg( feature = "processing" ) ]
185
- Outcome :: Accepted => OutcomeId :: ACCEPTED ,
186
180
Outcome :: Filtered ( _) | Outcome :: FilteredSampling ( _) => OutcomeId :: FILTERED ,
187
181
Outcome :: RateLimited ( _) => OutcomeId :: RATE_LIMITED ,
188
182
Outcome :: Invalid ( _) => OutcomeId :: INVALID ,
@@ -194,8 +188,6 @@ impl Outcome {
194
188
/// Returns the `reason` code field of this outcome.
195
189
fn to_reason ( & self ) -> Option < Cow < str > > {
196
190
match self {
197
- #[ cfg( feature = "processing" ) ]
198
- Outcome :: Accepted => None ,
199
191
Outcome :: Invalid ( discard_reason) => Some ( Cow :: Borrowed ( discard_reason. name ( ) ) ) ,
200
192
Outcome :: Filtered ( filter_key) => Some ( Cow :: Borrowed ( filter_key. name ( ) ) ) ,
201
193
Outcome :: FilteredSampling ( rule_ids) => Some ( Cow :: Owned ( format ! ( "Sampled:{rule_ids}" ) ) ) ,
@@ -228,8 +220,6 @@ impl Outcome {
228
220
impl fmt:: Display for Outcome {
229
221
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
230
222
match self {
231
- #[ cfg( feature = "processing" ) ]
232
- Outcome :: Accepted => write ! ( f, "accepted" ) ,
233
223
Outcome :: Filtered ( key) => write ! ( f, "filtered by {key}" ) ,
234
224
Outcome :: FilteredSampling ( rule_ids) => write ! ( f, "sampling rule {rule_ids}" ) ,
235
225
Outcome :: RateLimited ( None ) => write ! ( f, "rate limited" ) ,
@@ -796,16 +786,14 @@ impl OutcomeBroker {
796
786
}
797
787
798
788
#[ cfg( feature = "processing" ) ]
799
- fn send_kafka_message_inner (
789
+ fn send_kafka_message (
800
790
& self ,
801
791
producer : & KafkaOutcomesProducer ,
802
792
organization_id : u64 ,
803
793
message : TrackRawOutcome ,
804
794
) -> Result < ( ) , OutcomeError > {
805
795
relay_log:: trace!( "Tracking kafka outcome: {message:?}" ) ;
806
796
807
- send_outcome_metric ( & message, "kafka" ) ;
808
-
809
797
let payload = serde_json:: to_string ( & message) . map_err ( OutcomeError :: SerializationError ) ?;
810
798
811
799
// At the moment, we support outcomes with optional EventId.
@@ -835,23 +823,11 @@ impl OutcomeBroker {
835
823
}
836
824
}
837
825
838
- #[ cfg( feature = "processing" ) ]
839
- fn send_kafka_message (
840
- & self ,
841
- producer : & KafkaOutcomesProducer ,
842
- organization_id : u64 ,
843
- message : TrackRawOutcome ,
844
- ) -> Result < ( ) , OutcomeError > {
845
- for message in transform_outcome ( message) {
846
- self . send_kafka_message_inner ( producer, organization_id, message) ?;
847
- }
848
- Ok ( ( ) )
849
- }
850
-
851
826
fn handle_track_outcome ( & self , message : TrackOutcome , config : & Config ) {
852
827
match self {
853
828
#[ cfg( feature = "processing" ) ]
854
829
Self :: Kafka ( kafka_producer) => {
830
+ send_outcome_metric ( & message, "kafka" ) ;
855
831
let organization_id = message. scoping . organization_id ;
856
832
let raw_message = TrackRawOutcome :: from_outcome ( message, config) ;
857
833
if let Err ( error) =
@@ -876,6 +852,7 @@ impl OutcomeBroker {
876
852
match self {
877
853
#[ cfg( feature = "processing" ) ]
878
854
Self :: Kafka ( kafka_producer) => {
855
+ send_outcome_metric ( & message, "kafka" ) ;
879
856
let sharding_id = message. org_id . unwrap_or_else ( || message. project_id . value ( ) ) ;
880
857
if let Err ( error) = self . send_kafka_message ( kafka_producer, sharding_id, message) {
881
858
relay_log:: error!( error = & error as & dyn Error , "failed to produce outcome" ) ;
@@ -891,54 +868,6 @@ impl OutcomeBroker {
891
868
}
892
869
}
893
870
894
- /// Returns true if the outcome represents profiles dropped by dynamic sampling.
895
- #[ cfg( feature = "processing" ) ]
896
- fn is_sampled_profile ( outcome : & TrackRawOutcome ) -> bool {
897
- ( outcome. category == Some ( DataCategory :: Profile as u8 )
898
- || outcome. category == Some ( DataCategory :: ProfileIndexed as u8 ) )
899
- && outcome. outcome == OutcomeId :: FILTERED
900
- && outcome
901
- . reason
902
- . as_deref ( )
903
- . map_or ( false , |reason| reason. starts_with ( "Sampled:" ) )
904
- }
905
-
906
- /// Transform outcome into one or more derived outcome messages before sending it to kafka.
907
- #[ cfg( feature = "processing" ) ]
908
- fn transform_outcome ( mut outcome : TrackRawOutcome ) -> impl Iterator < Item = TrackRawOutcome > {
909
- let mut extra = None ;
910
- if is_sampled_profile ( & outcome) {
911
- // Profiles that were dropped by dynamic sampling still count as "processed",
912
- // so we emit the FILTERED outcome only for the "indexed" category instead.
913
- outcome. category = Some ( DataCategory :: ProfileIndexed as u8 ) ;
914
-
915
- // "processed" profiles are an abstract data category that does not represent actual data
916
- // going through our pipeline. Instead, the number of accepted "processed" profiles is counted as
917
- //
918
- // processed_profiles = indexed_profiles + sampled_profiles
919
- //
920
- // The "processed" outcome for indexed_profiles is generated in processing
921
- // (see `EnvelopeProcessor::count_processed_profiles()`),
922
- // but for profiles dropped by dynamic sampling, all we have is the FILTERED outcome,
923
- // which we transform into an ACCEPTED outcome here.
924
- //
925
- // The reason for doing this transformation in the kafka producer is that it should apply
926
- // to both `TrackOutcome` and `TrackRawOutcome`, and it should only happen _once_.
927
- //
928
- // In the future, we might actually extract metrics from profiles before dynamic sampling,
929
- // like we do for transactions. At that point, this code should be removed, and we should
930
- // enforce rate limits and emit outcomes based on the collect profile metric, as we do for
931
- // transactions.
932
- extra = Some ( TrackRawOutcome {
933
- outcome : OutcomeId :: ACCEPTED ,
934
- reason : None ,
935
- category : Some ( DataCategory :: Profile as u8 ) ,
936
- ..outcome. clone ( )
937
- } ) ;
938
- }
939
- Some ( outcome) . into_iter ( ) . chain ( extra)
940
- }
941
-
942
871
#[ derive( Debug ) ]
943
872
enum ProducerInner {
944
873
#[ cfg( feature = "processing" ) ]
0 commit comments