@@ -34,23 +34,15 @@ def start_process_message(event)
34
34
start_process_transaction ( event : event , kind : 'process_message' )
35
35
end
36
36
def process_message ( event )
37
- transaction = ElasticAPM . current_transaction
38
- error_present = !event . payload [ :unrecoverable_delivery_error ] . nil?
39
- transaction . outcome = error_present ? Transaction ::Outcome ::FAILURE : Transaction ::Outcome ::SUCCESS
40
- transaction . done ( error_present ? :error : :success )
41
-
37
+ record_outcome ( event : event )
42
38
ElasticAPM . end_transaction
43
39
end
44
40
45
41
def start_process_batch ( event )
46
42
start_process_transaction ( event : event , kind : 'process_batch' )
47
43
end
48
44
def process_batch ( event )
49
- transaction = ElasticAPM . current_transaction
50
- error_present = !event . payload [ :unrecoverable_delivery_error ] . nil?
51
- transaction . outcome = error_present ? Transaction ::Outcome ::FAILURE : Transaction ::Outcome ::SUCCESS
52
- transaction . done ( error_present ? :error : :success )
53
-
45
+ record_outcome ( event : event )
54
46
ElasticAPM . end_transaction
55
47
end
56
48
@@ -60,6 +52,13 @@ def start_process_transaction(event:, kind:)
60
52
ElasticAPM . start_transaction ( "#{ event . payload [ :consumer_class ] } ##{ kind } " , TYPE )
61
53
ElasticAPM . current_transaction . context . set_service ( framework_name : 'racecar' , framework_version : Racecar ::VERSION )
62
54
end
55
+
56
+ def record_outcome ( event :)
57
+ transaction = ElasticAPM . current_transaction
58
+ error_present = !event . payload [ :unrecoverable_delivery_error ] . nil?
59
+ transaction . outcome = error_present ? Transaction ::Outcome ::FAILURE : Transaction ::Outcome ::SUCCESS
60
+ transaction . done ( error_present ? :error : :success )
61
+ end
63
62
end
64
63
65
64
class ProducerSubscriber < ActiveSupport ::Subscriber
0 commit comments