37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/new_relic/rack/browser_monitoring.rb', line 37
def traced_call(env)
result = @app.call(env)
(status, , response) = result
js_to_inject = NewRelic::Agent.(nonce(env))
if (js_to_inject != NewRelic::EMPTY_STR) && should_instrument?(env, status, )
response_string = autoinstrument_source(response, js_to_inject)
if .key?(CONTENT_LENGTH)
content_length = response_string ? response_string.bytesize : 0
[CONTENT_LENGTH] = content_length.to_s
end
env[ALREADY_INSTRUMENTED_KEY] = true
if response_string
response = ::Rack::Response.new(response_string, status, )
response.finish
else
result
end
else
result
end
end
|