@@ -53,8 +53,7 @@ def capture_event(event, scope, hint = {})
53
53
return
54
54
end
55
55
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 )
58
57
59
58
is_transaction = event . is_a? ( TransactionEvent )
60
59
spans_before = is_transaction ? event . spans . size : 0
@@ -71,9 +70,7 @@ def capture_event(event, scope, hint = {})
71
70
transport . record_lost_event ( :event_processor , "span" , num : spans_delta ) if spans_delta > 0
72
71
end
73
72
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 )
77
74
unless dispatch_background_event ( event , hint )
78
75
transport . record_lost_event ( :queue_overflow , data_category )
79
76
transport . record_lost_event ( :queue_overflow , "span" , num : spans_before + 1 ) if is_transaction
@@ -176,11 +173,10 @@ def event_from_transaction(transaction)
176
173
177
174
# @!macro send_event
178
175
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 )
181
177
spans_before = event . is_a? ( TransactionEvent ) ? event . spans . size : 0
182
178
183
- if event_type != TransactionEvent ::TYPE && configuration . before_send
179
+ if event . type != TransactionEvent ::TYPE && configuration . before_send
184
180
event = configuration . before_send . call ( event , hint )
185
181
186
182
if event . nil?
@@ -190,7 +186,7 @@ def send_event(event, hint = nil)
190
186
end
191
187
end
192
188
193
- if event_type == TransactionEvent ::TYPE && configuration . before_send_transaction
189
+ if event . type == TransactionEvent ::TYPE && configuration . before_send_transaction
194
190
event = configuration . before_send_transaction . call ( event , hint )
195
191
196
192
if event . nil?
@@ -271,28 +267,5 @@ def dispatch_background_event(event, hint)
271
267
send_event ( event , hint )
272
268
end
273
269
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
297
270
end
298
271
end
0 commit comments