sensu 1.0.3 → 1.0.4
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/lib/sensu/api/http_handler.rb +20 -2
- data/lib/sensu/constants.rb +1 -1
- 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: 7340072ff38575eed6bc61c3ebdf267e6256b43e
|
4
|
+
data.tar.gz: 3abac29f261e891ddc35c8999dc3bd44c7bdc4dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98d1abcbd269002e00bcc0e78753ecdcca406771f945aa589d330fcea5acfabde81ce87eea3f359839c3b7e4a140b157c03d2b37a19716257e53f387e0d0983d
|
7
|
+
data.tar.gz: 3d70a5834d1e8d8fadd6893f53bebad799a54a235a24c5d77dff62899957a74334bc8d65dbecac854cd8cf8b26e195ecf470b5c2fa2dfc44bc81132ab7b4aa50
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "sensu/utilities"
|
1
2
|
require "sensu/api/routes"
|
2
3
|
require "sensu/api/utilities/filter_response_content"
|
3
4
|
|
@@ -21,9 +22,11 @@ module Sensu
|
|
21
22
|
# @result [Hash]
|
22
23
|
def request_details
|
23
24
|
return @request_details if @request_details
|
25
|
+
@request_id = @http.fetch(:x_request_id, random_uuid)
|
24
26
|
@request_start_time = Time.now.to_f
|
25
27
|
_, remote_address = Socket.unpack_sockaddr_in(get_peername)
|
26
28
|
@request_details = {
|
29
|
+
:request_id => @request_id,
|
27
30
|
:remote_address => remote_address,
|
28
31
|
:user_agent => @http[:user_agent],
|
29
32
|
:method => @http_request_method,
|
@@ -44,7 +47,9 @@ module Sensu
|
|
44
47
|
end
|
45
48
|
|
46
49
|
# Log the HTTP response. This method calculates the
|
47
|
-
# request/response time.
|
50
|
+
# request/response time. The debug log level is used for the
|
51
|
+
# response body log event, as it is generally very verbose and
|
52
|
+
# unnecessary in most cases.
|
48
53
|
def log_response
|
49
54
|
@logger.info("api response", {
|
50
55
|
:request => request_details,
|
@@ -52,6 +57,12 @@ module Sensu
|
|
52
57
|
:content_length => @response.content.to_s.bytesize,
|
53
58
|
:time => (Time.now.to_f - @request_start_time).round(3)
|
54
59
|
})
|
60
|
+
@logger.debug("api response body", {
|
61
|
+
:request => {
|
62
|
+
:request_id => @request_id
|
63
|
+
},
|
64
|
+
:content => @response.content
|
65
|
+
})
|
55
66
|
end
|
56
67
|
|
57
68
|
# Parse the HTTP request URI using a regular expression,
|
@@ -148,6 +159,13 @@ module Sensu
|
|
148
159
|
end
|
149
160
|
end
|
150
161
|
|
162
|
+
# Set the HTTP response headers, including the request ID and
|
163
|
+
# cors headers (via `set_cores_headers()`).
|
164
|
+
def set_headers
|
165
|
+
@response.headers["X-Request-ID"] = @request_id
|
166
|
+
set_cors_headers
|
167
|
+
end
|
168
|
+
|
151
169
|
# Paginate the provided items. This method uses two HTTP query
|
152
170
|
# parameters to determine how to paginate the items, `limit` and
|
153
171
|
# `offset`. The parameter `limit` specifies how many items are
|
@@ -392,7 +410,7 @@ module Sensu
|
|
392
410
|
log_request
|
393
411
|
parse_parameters
|
394
412
|
create_response
|
395
|
-
|
413
|
+
set_headers
|
396
414
|
if authorized?
|
397
415
|
if connected?
|
398
416
|
route_request
|
data/lib/sensu/constants.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|