Module: AppPerfRpm::Instruments::RackModule

Defined in:
lib/app_perf_rpm/instruments/rack.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
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
36
37
# File 'lib/app_perf_rpm/instruments/rack.rb', line 6

def call(env)
  req = ::Rack::Request.new(env)

  #if ::AppPerfRpm::Tracer.in_trace? &&
  #  ::AppPerfRpm.config.instrumentation[:rack][:trace_middleware]
  #  AppPerfRpm::Tracer.trace("rack-middleware") do |span|
  #    span.set_tag "type", "web"
  #    span.set_tag "domain", req.host
  #    span.set_tag "url", req.path
  #    span.set_tag "class", @app.class.name
  #
  #    status, headers, body = @app.call env
  #  end
  #else
  span = AppPerfRpm.tracer.start_span("rack")
  span.set_tag "type", "web"
  span.set_tag "domain", req.host
  span.set_tag "url", req.path
  span.set_tag "class", @app.class.name
  span.set_tag "backtrace", ::AppPerfRpm::Backtrace.backtrace
  span.set_tag "source", ::AppPerfRpm::Backtrace.source_extract

  @app.call(env)
rescue Exception => e
  if span
    span.set_tag('error', true)
    span.log_error(e)
  end
  raise
ensure
  span.finish if span
end