@@ -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
@@ -210,11 +207,10 @@ def event_from_transaction(transaction)
210207
211208 # @!macro send_event
212209 def send_event ( event , hint = nil )
213- event_type = event . is_a? ( Event ) ? event . type : event [ "type" ]
214- data_category = Envelope ::Item . data_category ( event_type )
210+ data_category = Envelope ::Item . data_category ( event . type )
215211 spans_before = event . is_a? ( TransactionEvent ) ? event . spans . size : 0
216212
217- if event_type != TransactionEvent ::TYPE && configuration . before_send
213+ if event . type != TransactionEvent ::TYPE && configuration . before_send
218214 event = configuration . before_send . call ( event , hint )
219215
220216 case event
@@ -235,7 +231,7 @@ def send_event(event, hint = nil)
235231 end
236232 end
237233
238- if event_type == TransactionEvent ::TYPE && configuration . before_send_transaction
234+ if event . type == TransactionEvent ::TYPE && configuration . before_send_transaction
239235 event = configuration . before_send_transaction . call ( event , hint )
240236
241237 if event . is_a? ( TransactionEvent ) || event . is_a? ( Hash )
@@ -373,28 +369,5 @@ def dispatch_background_event(event, hint)
373369 send_event ( event , hint )
374370 end
375371 end
376-
377- def dispatch_async_event ( async_block , event , hint )
378- # We have to convert to a JSON-like hash, because background job
379- # processors (esp ActiveJob) may not like weird types in the event hash
380-
381- event_hash =
382- begin
383- event . to_json_compatible
384- rescue => e
385- log_error ( "Converting #{ event . type } (#{ event . event_id } ) to JSON compatible hash failed" , e , debug : configuration . debug )
386- return
387- end
388-
389- if async_block . arity == 2
390- hint = JSON . parse ( JSON . generate ( hint ) )
391- async_block . call ( event_hash , hint )
392- else
393- async_block . call ( event_hash )
394- end
395- rescue => e
396- log_error ( "Async #{ event_hash [ "type" ] } sending failed" , e , debug : configuration . debug )
397- send_event ( event , hint )
398- end
399372 end
400373end
0 commit comments