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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/instana/instrumentation/rack.rb', line 7
def call(env)
kvs = { :http => {} }
kvs[:http][:method] = env['REQUEST_METHOD']
kvs[:http][:url] = ::CGI.unescape(env['PATH_INFO'])
if env.key?('HTTP_HOST')
kvs[:http][:host] = env['HTTP_HOST']
elsif env.key?('SERVER_NAME')
kvs[:http][:host] = env['SERVER_NAME']
end
incoming_context = {}
if env.key?('HTTP_X_INSTANA_T')
incoming_context[:trace_id] = ::Instana::Util.(env['HTTP_X_INSTANA_T'])
incoming_context[:span_id] = ::Instana::Util.(env['HTTP_X_INSTANA_S']) if env.key?('HTTP_X_INSTANA_S')
incoming_context[:level] = env['HTTP_X_INSTANA_L'] if env.key?('HTTP_X_INSTANA_L')
end
::Instana.tracer.log_start_or_continue(:rack, {}, incoming_context)
status, , response = @app.call(env)
if ::Instana.tracer.tracing?
kvs[:http][:status] = status
if status.between?(500, 511)
::Instana.tracer.log_error(nil)
end
trace_id = ::Instana.tracer.trace_id
span_id = ::Instana.tracer.span_id
end
[status, , response]
rescue Exception => e
::Instana.tracer.log_error(e)
raise
ensure
if && ::Instana.tracer.tracing?
['X-Instana-T'] = ::Instana::Util.(trace_id)
['X-Instana-S'] = ::Instana::Util.(span_id)
end
::Instana.tracer.log_end(:rack, kvs)
end
|