File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55- Correct type attribute's usages [ #1354 ] ( https://github.com/getsentry/sentry-ruby/pull/1354 )
66- Fix sampling decision precedence [ #1335 ] ( https://github.com/getsentry/sentry-ruby/pull/1335 )
77- Fix set_contexts [ #1375 ] ( https://github.com/getsentry/sentry-ruby/pull/1375 )
8+ - Use thread variable instead of fiber variable to store the hub [ #1380 ] ( https://github.com/getsentry/sentry-ruby/pull/1380 )
9+ - Fixes [ #1374 ] ( https://github.com/getsentry/sentry-ruby/issues/1374 )
810
911## 4.3.1
1012
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def init(&block)
6868 client = Client . new ( config )
6969 scope = Scope . new ( max_breadcrumbs : config . max_breadcrumbs )
7070 hub = Hub . new ( client , scope )
71- Thread . current [ THREAD_LOCAL ] = hub
71+ Thread . current . thread_variable_set ( THREAD_LOCAL , hub )
7272 @main_hub = hub
7373 @background_worker = Sentry ::BackgroundWorker . new ( config )
7474 end
@@ -92,7 +92,7 @@ def get_current_hub
9292 # ideally, we should do this proactively whenever a new thread is created
9393 # but it's impossible for the SDK to keep track every new thread
9494 # so we need to use this rather passive way to make sure the app doesn't crash
95- Thread . current [ THREAD_LOCAL ] || clone_hub_to_current_thread
95+ Thread . current . thread_variable_get ( THREAD_LOCAL ) || clone_hub_to_current_thread
9696 end
9797
9898 # Returns the current active client.
@@ -107,7 +107,7 @@ def get_current_scope
107107
108108 # Clones the main thread's active hub and stores it to the current thread.
109109 def clone_hub_to_current_thread
110- Thread . current [ THREAD_LOCAL ] = get_main_hub . clone
110+ Thread . current . thread_variable_set ( THREAD_LOCAL , get_main_hub . clone )
111111 end
112112
113113 # Takes a block and yields the current active scope.
Original file line number Diff line number Diff line change 6464
6565 new_thread . join
6666 end
67+
68+ it "stores the hub in a thread variable (instead of just fiber variable)" do
69+ Sentry . set_tags ( outside_fiber : true )
70+
71+ fiber = Fiber . new do
72+ Sentry . set_tags ( inside_fiber : true )
73+ end
74+
75+ fiber . resume
76+
77+ expect ( Sentry . get_current_scope . tags ) . to eq ( { outside_fiber : true , inside_fiber : true } )
78+ end
6779 end
6880
6981 describe ".configure_scope" do
You can’t perform that action at this time.
0 commit comments