lib/logjam_agent/request.rb in logjam_agent-0.3.4 vs lib/logjam_agent/request.rb in logjam_agent-0.3.5
- old
+ new
@@ -1,15 +1,26 @@
require "json"
module LogjamAgent
class Request
- attr_reader :fields
+ attr_reader :caller_id, :fields
def initialize(app, env, logger, initial_fields)
@logger = logger
+ @app = app
+ @env = env
@forwarder = Forwarders.get(app, env)
@lines = []
- @fields = initial_fields.merge(:host => LogjamAgent.hostname, :process_id => Process.pid, :lines => @lines)
+ @id = UUID4R::uuid(1).gsub('-','')
+ @fields = initial_fields.merge(:request_id => @id, :host => LogjamAgent.hostname, :process_id => Process.pid, :lines => @lines)
+ end
+
+ def id
+ "#{@app}-#{@env}-#{@id}"
+ end
+
+ def caller_id
+ @fields[:caller_id]
end
def add_line(severity, timestamp, message)
@lines << [severity, format_time(timestamp), message.strip]
end