Class: AppPerfRpm::Instruments::Rack
- Inherits:
-
Object
- Object
- AppPerfRpm::Instruments::Rack
- Defined in:
- lib/app_perf_rpm/instruments/rack.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #ignore_path?(path) ⇒ Boolean
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
6 7 8 |
# File 'lib/app_perf_rpm/instruments/rack.rb', line 6 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
4 5 6 |
# File 'lib/app_perf_rpm/instruments/rack.rb', line 4 def app @app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/app_perf_rpm/instruments/rack.rb', line 10 def call(env) req = ::Rack::Request.new(env) incoming_trace = env["HTTP_X_APP_PERF_TRACE"] incoming_trace_id = env["HTTP_X_APP_PERF_TRACE_ID"] opts = {} if incoming_trace.to_s.eql?("1") opts.merge!("trace_id" => incoming_trace_id) end if ignore_path?(req.path) @status, @headers, @response = @app.call(env) else AppPerfRpm::Tracer.start_trace("rack", opts) do |span| span.type = "web" span.domain = req.host span.url = req.path span.["class"] = self.class.name @status, @headers, @response = @app.call(env) end end [@status, @headers, @response] end |
#ignore_path?(path) ⇒ Boolean
37 38 39 |
# File 'lib/app_perf_rpm/instruments/rack.rb', line 37 def ignore_path?(path) path.to_s =~ /\/assets/ end |