File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ def dup
135135 copy . session = session . deep_dup
136136 copy . propagation_context = propagation_context . deep_dup
137137 copy . attachments = attachments . dup
138+ copy . event_processors = event_processors . dup
138139 copy
139140 end
140141
Original file line number Diff line number Diff line change 402402 expect ( outter_event . tags ) . to eq ( { level : 1 } )
403403 end
404404
405+ it "doesn't leak event processors to the outer scope" do
406+ processor_calls = 0
407+
408+ 2 . times do
409+ subject . with_scope do |scope |
410+ scope . add_event_processor do |event , _hint |
411+ processor_calls += 1
412+ event
413+ end
414+
415+ subject . capture_message ( "test" )
416+ end
417+ end
418+
419+ expect ( processor_calls ) . to eq ( 2 )
420+ end
421+
405422 it "doesn't leak data mutation" do
406423 inner_event = nil
407424 scope . set_tags ( { level : 1 } )
Original file line number Diff line number Diff line change 5757 expect ( subject . span ) . to eq ( nil )
5858 end
5959
60+ it "copies event_processors so mutations don't affect the original" do
61+ subject . add_event_processor { |event , _hint | event }
62+ copy = subject . dup
63+
64+ copy . add_event_processor { |event , _hint | event }
65+
66+ expect ( subject . event_processors . length ) . to eq ( 1 )
67+ expect ( copy . event_processors . length ) . to eq ( 2 )
68+ end
69+
6070 it "deep-copies span as well" do
6171 perform_basic_setup
6272
You can’t perform that action at this time.
0 commit comments