Module: Webmachine::Trace::FSM
- Defined in:
- lib/webmachine/trace/fsm.rb
Overview
This module is injected into Decision::FSM when tracing is enabled for a resource, enabling the capturing of traces.
Instance Method Summary collapse
-
#resource ⇒ Object
Overrides the default resource accessor so that incoming callbacks are traced.
-
#trace_decision(decision) ⇒ Object
Adds a decision to the trace.
-
#trace_request(request) ⇒ Object
Adds the request to the trace.
-
#trace_response(response) ⇒ Object
Adds the response to the trace and then commits the trace to separate storage which can be discovered by the debugger.
Instance Method Details
#resource ⇒ Object
Overrides the default resource accessor so that incoming callbacks are traced.
41 42 43 |
# File 'lib/webmachine/trace/fsm.rb', line 41 def resource @resource_proxy ||= ResourceProxy.new(@resource) end |
#trace_decision(decision) ⇒ Object
Adds a decision to the trace.
35 36 37 |
# File 'lib/webmachine/trace/fsm.rb', line 35 def trace_decision(decision) response.trace << {:type => :decision, :decision => decision} end |
#trace_request(request) ⇒ Object
Adds the request to the trace.
9 10 11 12 13 14 15 16 17 |
# File 'lib/webmachine/trace/fsm.rb', line 9 def trace_request(request) response.trace << { :type => :request, :method => request.method, :path => request.uri.request_uri.to_s, :headers => request.headers, :body => request.body.to_s } end |
#trace_response(response) ⇒ Object
Adds the response to the trace and then commits the trace to separate storage which can be discovered by the debugger.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/webmachine/trace/fsm.rb', line 22 def trace_response(response) response.trace << { :type => :response, :code => response.code.to_s, :headers => response.headers, :body => trace_response_body(response.body) } ensure Trace.record(resource.object_id.to_s, response.trace) end |