Module: NewRelic::ThreadLocalStorage

Defined in:
lib/new_relic/thread_local_storage.rb

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



23
24
25
# File 'lib/new_relic/thread_local_storage.rb', line 23

def self.[](key)
  get(::Thread.current, key)
end

.[]=(key, value) ⇒ Object



27
28
29
# File 'lib/new_relic/thread_local_storage.rb', line 27

def self.[]=(key, value)
  set(::Thread.current, key, value)
end

.get(thread, key) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/new_relic/thread_local_storage.rb', line 7

def self.get(thread, key)
  if Agent.config[:thread_local_tracer_state]
    thread.thread_variable_get(key)
  else
    thread[key]
  end
end

.set(thread, key, value) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/new_relic/thread_local_storage.rb', line 15

def self.set(thread, key, value)
  if Agent.config[:thread_local_tracer_state]
    thread.thread_variable_set(key, value)
  else
    thread[key] = value
  end
end