right_support 2.9.2 → 2.9.3
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/right_support/rack/request_logger.rb +13 -9
- data/right_support.gemspec +3 -3
- data/spec/rack/request_logger_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37afc64ef433ebff859d8ceee0fb88c158609480
|
4
|
+
data.tar.gz: cee57ea2de6dca374c35df0337af297192d01176
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27c7985c33dca1f7a28b811ea02849d93b1ecc53feecbb83e7e08594bb1008e1d31ca3a8d7f0910892235a4b01be62fd37342673ca2462e172f3dcb2321af6b0
|
7
|
+
data.tar.gz: 9a30f91c3411fa31619b67f24f6bd8611b7fc1e7fe28c2cb0f90e39bdbec6094624b6463ee519bd9e0e556775f6c32917449e58f9879beb76a11902660cdd4e5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.9.
|
1
|
+
2.9.3
|
@@ -76,7 +76,7 @@ module RightSupport::Rack
|
|
76
76
|
if env['sinatra.error'] && !env['sinatra.error.handled']
|
77
77
|
log_exception(logger, env['sinatra.error'])
|
78
78
|
end
|
79
|
-
log_request_end(logger, status, header, body, began_at) if enabled
|
79
|
+
log_request_end(logger, env, status, header, body, began_at) if enabled
|
80
80
|
|
81
81
|
return [status, header, body]
|
82
82
|
rescue Exception => e
|
@@ -117,8 +117,11 @@ module RightSupport::Rack
|
|
117
117
|
#
|
118
118
|
# @return [TrueClass] always true
|
119
119
|
def log_request_begin(logger, env)
|
120
|
-
# Assuming remote addresses are IPv4, make them all align to the same
|
121
|
-
|
120
|
+
# Assuming remote addresses are IPv4, make them all align to the same
|
121
|
+
# width
|
122
|
+
remote_addr = env['HTP_X_REAL_IP'] ||
|
123
|
+
env['HTTP_X_FORWARDED_FOR'] ||
|
124
|
+
env["REMOTE_ADDR"] || "-"
|
122
125
|
remote_addr = remote_addr.ljust(15)
|
123
126
|
|
124
127
|
# If we're not logging the contents of the query string we only log the fact that a query
|
@@ -142,16 +145,16 @@ module RightSupport::Rack
|
|
142
145
|
shard_info = 'Shard: ' + (env['HTTP_X_SHARD'] || 'default').to_s + ';'
|
143
146
|
|
144
147
|
params = [
|
145
|
-
env[
|
146
|
-
env[
|
148
|
+
env['REQUEST_METHOD'],
|
149
|
+
env['PATH_INFO'],
|
147
150
|
query_info,
|
148
151
|
remote_addr,
|
149
152
|
sess,
|
150
153
|
shard_info,
|
151
|
-
env[
|
154
|
+
env['rack.request_uuid'] || ''
|
152
155
|
]
|
153
156
|
|
154
|
-
logger.info
|
157
|
+
logger.info 'Processing %s "%s%s" (for %s) %s %s Request ID: %s' % params
|
155
158
|
end
|
156
159
|
|
157
160
|
# Log end of request
|
@@ -162,7 +165,7 @@ module RightSupport::Rack
|
|
162
165
|
# @param [Time] began_at time of the Rack request beginning
|
163
166
|
#
|
164
167
|
# @return [TrueClass] always true
|
165
|
-
def log_request_end(logger, status, headers, body, began_at)
|
168
|
+
def log_request_end(logger, env, status, headers, body, began_at)
|
166
169
|
duration = (Time.now - began_at) * 1000
|
167
170
|
|
168
171
|
# Downcase keys in the headers Hash for case-insensitive comparisons
|
@@ -184,9 +187,10 @@ module RightSupport::Rack
|
|
184
187
|
duration,
|
185
188
|
"#{status} #{Rack::Utils::HTTP_STATUS_CODES[status]}",
|
186
189
|
content_length.to_s,
|
190
|
+
env['rack.request_uuid'] || ''
|
187
191
|
]
|
188
192
|
|
189
|
-
logger.info
|
193
|
+
logger.info 'Completed in %dms | %s | %s bytes | Request ID: %s' % params
|
190
194
|
end
|
191
195
|
|
192
196
|
# Log exception
|
data/right_support.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: right_support 2.9.
|
5
|
+
# stub: right_support 2.9.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "right_support"
|
9
|
-
s.version = "2.9.
|
9
|
+
s.version = "2.9.3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Tony Spataro", "Sergey Sergyenko", "Ryan Williamson", "Lee Kirchhoff", "Alexey Karpik", "Scott Messier"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-11-02"
|
15
15
|
s.description = "A toolkit of useful, reusable foundation code created by RightScale."
|
16
16
|
s.email = "support@rightscale.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -141,5 +141,21 @@ describe RightSupport::Rack::RequestLogger do
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
context 'request ID logging' do
|
145
|
+
before(:each) do
|
146
|
+
@logger = mock_logger
|
147
|
+
@env['rack.request_uuid'] = 'some-uuid'
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'tags the Processing line' do
|
151
|
+
@logger.should_receive(:info).with(FlexMock.on { |arg| arg.should =~ /Request ID: some-uuid/ } )
|
152
|
+
@middleware.send(:log_request_begin, @logger, @env)
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'tags the Completed line' do
|
156
|
+
@logger.should_receive(:info).with(FlexMock.on { |arg| arg.should =~ /Request ID: some-uuid/ } )
|
157
|
+
@middleware.send(:log_request_end, @logger, @env, 200, {}, '', Time.now)
|
158
|
+
end
|
159
|
+
end
|
144
160
|
end
|
145
161
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Spataro
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2015-
|
16
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rake
|