File tree 2 files changed +19
-8
lines changed
2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ def process_batch(_event)
47
47
private # only public methods will be subscribed
48
48
49
49
def start_process_transaction ( event :, kind :)
50
- ElasticAPM . start_transaction ( kind , TYPE )
50
+ ElasticAPM . start_transaction ( " #{ event . payload [ :consumer_class ] } # #{ kind } " , TYPE )
51
51
ElasticAPM . current_transaction . context . set_service ( framework_name : 'racecar' , framework_version : Racecar ::VERSION )
52
52
end
53
53
end
@@ -74,4 +74,5 @@ def install
74
74
75
75
rescue LoadError
76
76
# no active support available
77
+ STDERR . puts "ActiveSupport not found."
77
78
end
Original file line number Diff line number Diff line change 18
18
# frozen_string_literal: true
19
19
20
20
require 'spec_helper'
21
-
22
21
begin
23
22
require 'active_support/notifications'
24
- require " active_support/subscriber"
23
+ require ' active_support/subscriber'
25
24
require 'racecar'
26
-
27
25
module ElasticAPM
28
26
RSpec . describe 'Spy: Racecar' , :intercept do
29
27
it 'captures the instrumentation' do
30
28
with_agent do
31
- ActiveSupport ::Notifications . instrument ( 'start_process_message.racecar' )
32
- ActiveSupport ::Notifications . instrument ( 'process_message.racecar' ) do
29
+ instrumentation_payload = {
30
+ consumer_class : 'SpecConsumer' ,
31
+ topic : 'spec_topic' ,
32
+ partition : '0' ,
33
+ offset : '1' ,
34
+ create_time : Time . now ,
35
+ key : '1' ,
36
+ value : { key : 'value' } ,
37
+ headers : { key : 'value' }
38
+ }
39
+ ActiveSupport ::Notifications . instrument ( 'start_process_message.racecar' , instrumentation_payload )
40
+ ActiveSupport ::Notifications . instrument ( 'process_message.racecar' , instrumentation_payload ) do
33
41
# this is the body of the racecar consumer #process method
34
42
end
35
43
first_transaction = @intercepted . transactions . first
36
44
expect ( first_transaction ) . not_to be_nil
37
- expect ( first_transaction . name ) . to eq ( ' process_message' )
45
+ expect ( first_transaction . name ) . to eq ( " #{ instrumentation_payload [ :consumer_class ] } # process_message" )
38
46
expect ( first_transaction . type ) . to eq ( 'kafka' )
47
+ expect ( first_transaction . context . service . framework . name ) . to eq ( 'racecar' )
39
48
end
40
49
end
41
50
end
42
51
end
43
52
44
53
rescue LoadError # in case we don't have ActiveSupport
45
- end
54
+ STDERR . puts "ActiveSupport not found, skipping."
55
+ end
You can’t perform that action at this time.
0 commit comments