rack-instruments 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rack/instruments.rb +9 -3
- metadata +1 -1
data/lib/rack/instruments.rb
CHANGED
@@ -25,11 +25,18 @@ module Rack
|
|
25
25
|
env["REQUEST_PATH"] =~ /\.#{ext}$/
|
26
26
|
}
|
27
27
|
|
28
|
-
request_ids = [@request_id_generator.call]
|
28
|
+
request_ids = [@request_id_generator.call]
|
29
29
|
status, headers, response = nil, nil, nil
|
30
30
|
|
31
31
|
# make ID of the request accessible to consumers down the stack
|
32
|
-
env["REQUEST_ID"] = request_ids
|
32
|
+
env["REQUEST_ID"] = request_ids[0]
|
33
|
+
|
34
|
+
# Extract request IDs from incoming headers as well. Can be used for
|
35
|
+
# identifying a request across a number of components in SOA.
|
36
|
+
if @header_request_ids
|
37
|
+
request_ids += extract_request_ids(env)
|
38
|
+
env["REQUEST_IDS"] = request_ids
|
39
|
+
end
|
33
40
|
|
34
41
|
data = [
|
35
42
|
[:method, env["REQUEST_METHOD"]],
|
@@ -51,7 +58,6 @@ module Rack
|
|
51
58
|
private
|
52
59
|
|
53
60
|
def extract_request_ids(env)
|
54
|
-
return [] unless @header_request_ids
|
55
61
|
request_ids = []
|
56
62
|
if env["HTTP_REQUEST_ID"]
|
57
63
|
request_ids = env["HTTP_REQUEST_ID"].split(",")
|