@@ -60,8 +60,7 @@ def capture_event(event, scope, hint = {})
6060 return
6161 end
6262
63- event_type = event . is_a? ( Event ) ? event . type : event [ "type" ]
64- data_category = Envelope ::Item . data_category ( event_type )
63+ data_category = Envelope ::Item . data_category ( event . type )
6564
6665 is_transaction = event . is_a? ( TransactionEvent )
6766 spans_before = is_transaction ? event . spans . size : 0
@@ -78,9 +77,7 @@ def capture_event(event, scope, hint = {})
7877 transport . record_lost_event ( :event_processor , "span" , num : spans_delta ) if spans_delta > 0
7978 end
8079
81- if async_block = configuration . async
82- dispatch_async_event ( async_block , event , hint )
83- elsif configuration . background_worker_threads != 0 && hint . fetch ( :background , true )
80+ if configuration . background_worker_threads != 0 && hint . fetch ( :background , true )
8481 unless dispatch_background_event ( event , hint )
8582 transport . record_lost_event ( :queue_overflow , data_category )
8683 transport . record_lost_event ( :queue_overflow , "span" , num : spans_before + 1 ) if is_transaction
@@ -209,11 +206,10 @@ def event_from_transaction(transaction)
209206
210207 # @!macro send_event
211208 def send_event ( event , hint = nil )
212- event_type = event . is_a? ( Event ) ? event . type : event [ "type" ]
213- data_category = Envelope ::Item . data_category ( event_type )
209+ data_category = Envelope ::Item . data_category ( event . type )
214210 spans_before = event . is_a? ( TransactionEvent ) ? event . spans . size : 0
215211
216- if event_type != TransactionEvent ::TYPE && configuration . before_send
212+ if event . type != TransactionEvent ::TYPE && configuration . before_send
217213 event = configuration . before_send . call ( event , hint )
218214
219215 case event
@@ -234,7 +230,7 @@ def send_event(event, hint = nil)
234230 end
235231 end
236232
237- if event_type == TransactionEvent ::TYPE && configuration . before_send_transaction
233+ if event . type == TransactionEvent ::TYPE && configuration . before_send_transaction
238234 event = configuration . before_send_transaction . call ( event , hint )
239235
240236 if event . is_a? ( TransactionEvent ) || event . is_a? ( Hash )
@@ -372,28 +368,5 @@ def dispatch_background_event(event, hint)
372368 send_event ( event , hint )
373369 end
374370 end
375-
376- def dispatch_async_event ( async_block , event , hint )
377- # We have to convert to a JSON-like hash, because background job
378- # processors (esp ActiveJob) may not like weird types in the event hash
379-
380- event_hash =
381- begin
382- event . to_json_compatible
383- rescue => e
384- log_error ( "Converting #{ event . type } (#{ event . event_id } ) to JSON compatible hash failed" , e , debug : configuration . debug )
385- return
386- end
387-
388- if async_block . arity == 2
389- hint = JSON . parse ( JSON . generate ( hint ) )
390- async_block . call ( event_hash , hint )
391- else
392- async_block . call ( event_hash )
393- end
394- rescue => e
395- log_error ( "Async #{ event_hash [ "type" ] } sending failed" , e , debug : configuration . debug )
396- send_event ( event , hint )
397- end
398371 end
399372end
0 commit comments