Class: Wildsight::Context::Context

Inherits:
Object
  • Object
show all
Includes:
ActiveRecord, Exception, Logs, Rack, Rails
Defined in:
lib/wildsight/context/context.rb

Constant Summary

Constants included from Rack

Rack::RACK_ENV_KEY, Rack::REQUEST_EXCLUDE_KEYS, Rack::REQUEST_INCLUDE_KEYS, Rack::RESPONSE_EXCLUDE_KEYS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveRecord

#active_record_data, #active_record_report

Methods included from Rails

#rails_data, #rails_extract

Methods included from Rack

detect_context, #rack_data, #rack_instrument_request, #rack_report

Methods included from Exception

#exception_data, #exception_extract, #exception_report

Methods included from Logs

#log_data, #log_report

Constructor Details

#initialize(name, agent) ⇒ Context

Returns a new instance of Context.



24
25
26
27
28
# File 'lib/wildsight/context/context.rb', line 24

def initialize(name, agent)
  @name = name
  @agent = agent
  @data = {}
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/wildsight/context/context.rb', line 22

def name
  @name
end

Class Method Details

.thread_context_id(thread = Thread.current) ⇒ Object



54
55
56
# File 'lib/wildsight/context/context.rb', line 54

def self.thread_context_id(thread=Thread.current)
  thread.thread_variable_get('wildsight.context')
end

Instance Method Details

#bind_thread(thread = Thread.current) ⇒ Object



38
39
40
# File 'lib/wildsight/context/context.rb', line 38

def bind_thread(thread = Thread.current)
  thread.thread_variable_set('wildsight.context', self)
end

#dataObject



46
47
48
# File 'lib/wildsight/context/context.rb', line 46

def data
  @data
end

#profilerObject



50
51
52
# File 'lib/wildsight/context/context.rb', line 50

def profiler
  @profiler ||= ::Wildsight::Profiler::Profiler.new(self)
end

#release_thread(thread = Thread.current) ⇒ Object



42
43
44
# File 'lib/wildsight/context/context.rb', line 42

def release_thread(thread = Thread.current)
  thread.thread_variable_set('wildsight.context', nil)
end

#submitObject



30
31
32
# File 'lib/wildsight/context/context.rb', line 30

def submit
  @agent.submit({ :context => { :id => @name }, :payload => @data })
end

#unregisterObject



34
35
36
# File 'lib/wildsight/context/context.rb', line 34

def unregister
  @agent.unregister_context(self)
end