@@ -53,8 +53,7 @@ def capture_event(event, scope, hint = {})
5353 return
5454 end
5555
56- event_type = event . is_a? ( Event ) ? event . type : event [ "type" ]
57- data_category = Envelope ::Item . data_category ( event_type )
56+ data_category = Envelope ::Item . data_category ( event . type )
5857
5958 is_transaction = event . is_a? ( TransactionEvent )
6059 spans_before = is_transaction ? event . spans . size : 0
@@ -71,9 +70,7 @@ def capture_event(event, scope, hint = {})
7170 transport . record_lost_event ( :event_processor , "span" , num : spans_delta ) if spans_delta > 0
7271 end
7372
74- if async_block = configuration . async
75- dispatch_async_event ( async_block , event , hint )
76- elsif configuration . background_worker_threads != 0 && hint . fetch ( :background , true )
73+ if configuration . background_worker_threads != 0 && hint . fetch ( :background , true )
7774 unless dispatch_background_event ( event , hint )
7875 transport . record_lost_event ( :queue_overflow , data_category )
7976 transport . record_lost_event ( :queue_overflow , "span" , num : spans_before + 1 ) if is_transaction
@@ -176,11 +173,10 @@ def event_from_transaction(transaction)
176173
177174 # @!macro send_event
178175 def send_event ( event , hint = nil )
179- event_type = event . is_a? ( Event ) ? event . type : event [ "type" ]
180- data_category = Envelope ::Item . data_category ( event_type )
176+ data_category = Envelope ::Item . data_category ( event . type )
181177 spans_before = event . is_a? ( TransactionEvent ) ? event . spans . size : 0
182178
183- if event_type != TransactionEvent ::TYPE && configuration . before_send
179+ if event . type != TransactionEvent ::TYPE && configuration . before_send
184180 event = configuration . before_send . call ( event , hint )
185181
186182 if event . nil?
@@ -190,7 +186,7 @@ def send_event(event, hint = nil)
190186 end
191187 end
192188
193- if event_type == TransactionEvent ::TYPE && configuration . before_send_transaction
189+ if event . type == TransactionEvent ::TYPE && configuration . before_send_transaction
194190 event = configuration . before_send_transaction . call ( event , hint )
195191
196192 if event . nil?
@@ -271,28 +267,5 @@ def dispatch_background_event(event, hint)
271267 send_event ( event , hint )
272268 end
273269 end
274-
275- def dispatch_async_event ( async_block , event , hint )
276- # We have to convert to a JSON-like hash, because background job
277- # processors (esp ActiveJob) may not like weird types in the event hash
278-
279- event_hash =
280- begin
281- event . to_json_compatible
282- rescue => e
283- log_error ( "Converting #{ event . type } (#{ event . event_id } ) to JSON compatible hash failed" , e , debug : configuration . debug )
284- return
285- end
286-
287- if async_block . arity == 2
288- hint = JSON . parse ( JSON . generate ( hint ) )
289- async_block . call ( event_hash , hint )
290- else
291- async_block . call ( event_hash )
292- end
293- rescue => e
294- log_error ( "Async #{ event_hash [ "type" ] } sending failed" , e , debug : configuration . debug )
295- send_event ( event , hint )
296- end
297270 end
298271end
0 commit comments