Class: ScoutApm::Remote::Recorder
- Inherits:
-
Object
- Object
- ScoutApm::Remote::Recorder
- Defined in:
- lib/scout_apm/remote/recorder.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#remote_agent_host ⇒ Object
readonly
Returns the value of attribute remote_agent_host.
-
#remote_agent_port ⇒ Object
readonly
Returns the value of attribute remote_agent_port.
Instance Method Summary collapse
-
#initialize(remote_agent_host, remote_agent_port, logger) ⇒ Recorder
constructor
A new instance of Recorder.
- #post(encoded_message) ⇒ Object
- #record!(request) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(remote_agent_host, remote_agent_port, logger) ⇒ Recorder
Returns a new instance of Recorder.
8 9 10 11 12 |
# File 'lib/scout_apm/remote/recorder.rb', line 8 def initialize(remote_agent_host, remote_agent_port, logger) @remote_agent_host = remote_agent_host @remote_agent_port = remote_agent_port @logger = logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/scout_apm/remote/recorder.rb', line 4 def logger @logger end |
#remote_agent_host ⇒ Object (readonly)
Returns the value of attribute remote_agent_host.
5 6 7 |
# File 'lib/scout_apm/remote/recorder.rb', line 5 def remote_agent_host @remote_agent_host end |
#remote_agent_port ⇒ Object (readonly)
Returns the value of attribute remote_agent_port.
6 7 8 |
# File 'lib/scout_apm/remote/recorder.rb', line 6 def remote_agent_port @remote_agent_port end |
Instance Method Details
#post(encoded_message) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/scout_apm/remote/recorder.rb', line 49 def post() http = Net::HTTP.new(remote_agent_host, remote_agent_port) request = Net::HTTP::Post.new("/users") request.body = response = http.request(request) end |
#record!(request) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/scout_apm/remote/recorder.rb', line 23 def record!(request) begin t1 = Time.now # Mark this request as recorded, so the next lookup on this thread, it # can be recreated request.recorded! # Only send requests that we actually want. Incidental http & # background thread stuff can just be dropped unless request.job? || request.web? return end request.prepare_to_dump! = ScoutApm::Remote::Message.new('record', 'record!', request) encoded = .encode logger.debug "Remote Agent: Posting a message of length: #{encoded.length}" post(encoded) t2 = Time.now logger.debug("Remote Recording took: #{t2.to_f - t1.to_f} seconds") rescue => e logger.debug "Remote: Error while sending to collector: #{e.inspect}, #{e.backtrace.join("\n")}" end end |
#start ⇒ Object
14 15 16 17 |
# File 'lib/scout_apm/remote/recorder.rb', line 14 def start # nothing to do self end |
#stop ⇒ Object
19 20 21 |
# File 'lib/scout_apm/remote/recorder.rb', line 19 def stop # nothing to do end |