Class: LogjamAgent::Request
- Inherits:
-
Object
- Object
- LogjamAgent::Request
- Defined in:
- lib/logjam_agent/request.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #action ⇒ Object
- #add_exception(exception) ⇒ Object
- #add_line(severity, timestamp, message) ⇒ Object
- #caller_action ⇒ Object
- #caller_id ⇒ Object
- #forward ⇒ Object
- #id ⇒ Object
- #ignore! ⇒ Object
- #ignored? ⇒ Boolean
-
#initialize(app, env, initial_fields) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(app, env, initial_fields) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/logjam_agent/request.rb', line 11 def initialize(app, env, initial_fields) @app = app @env = env @forwarder = Forwarders.get(app, env) @lines = [] @uuid = LogjamAgent.generate_uuid @fields = initial_fields.merge(:request_id => @uuid, :host => LogjamAgent.hostname, :process_id => Process.pid, :lines => @lines) @mutex = Mutex.new @ignored = false end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
9 10 11 |
# File 'lib/logjam_agent/request.rb', line 9 def fields @fields end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
9 10 11 |
# File 'lib/logjam_agent/request.rb', line 9 def uuid @uuid end |
Instance Method Details
#action ⇒ Object
34 35 36 |
# File 'lib/logjam_agent/request.rb', line 34 def action @fields[:action] end |
#add_exception(exception) ⇒ Object
52 53 54 55 56 |
# File 'lib/logjam_agent/request.rb', line 52 def add_exception(exception) @mutex.synchronize do ((@fields[:exceptions] ||= []) << exception).uniq! end end |
#add_line(severity, timestamp, message) ⇒ Object
46 47 48 49 50 |
# File 'lib/logjam_agent/request.rb', line 46 def add_line(severity, , ) @mutex.synchronize do @lines << [severity, format_time(), .strip] end end |
#caller_action ⇒ Object
42 43 44 |
# File 'lib/logjam_agent/request.rb', line 42 def caller_action @fields[:caller_action] end |
#caller_id ⇒ Object
38 39 40 |
# File 'lib/logjam_agent/request.rb', line 38 def caller_id @fields[:caller_id] end |
#forward ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/logjam_agent/request.rb', line 58 def forward return if @ignored engine = @fields.delete(:engine) # puts @fields.inspect @forwarder.forward(LogjamAgent.encode_payload(@fields), :engine => engine) rescue Exception => e handle_forwarding_error(e) end |
#id ⇒ Object
30 31 32 |
# File 'lib/logjam_agent/request.rb', line 30 def id "#{@app}-#{@env}-#{@uuid}" end |
#ignore! ⇒ Object
22 23 24 |
# File 'lib/logjam_agent/request.rb', line 22 def ignore! @ignored = true end |
#ignored? ⇒ Boolean
26 27 28 |
# File 'lib/logjam_agent/request.rb', line 26 def ignored? @ignored end |