logtail-rack 0.2.7 → 0.2.8
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/logtail-rack/http_events.rb +15 -9
- data/lib/logtail-rack/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 491ec5e9eed4646a543ceda9f205b64687c5cc86299940ad23b920e83097bd69
|
|
4
|
+
data.tar.gz: 3063069043ec64c72e74c52ea00a0d033a21590bdc89369e984b75ff580fc83c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac332a52ed1a822b42e23fe852736276a87ae828f54ddc6c281b54a249a9a21c8e768b0553df688654644c414ae1db51cab4b4c8e1657d88535e32a9a78ecabf
|
|
7
|
+
data.tar.gz: 0e336672e86b16a1c85b62feb34939c4d241417e7e31af02b18ef36a29f0d63882c53bb91c2751b6fb12ee61841057b4e092877ee026948a75d1c746874d7a8f
|
|
@@ -130,7 +130,7 @@ module Logtail
|
|
|
130
130
|
|
|
131
131
|
self.http_header_filters = DEFAULT_HTTP_HEADER_FILTERS
|
|
132
132
|
|
|
133
|
-
CONTENT_LENGTH_KEY = '
|
|
133
|
+
CONTENT_LENGTH_KEY = 'content-length'.freeze
|
|
134
134
|
|
|
135
135
|
def call(env)
|
|
136
136
|
request = Util::Request.new(env)
|
|
@@ -145,14 +145,14 @@ module Logtail
|
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
elsif collapse_into_single_event?
|
|
148
|
-
request_start =
|
|
148
|
+
request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
149
149
|
status, headers, body = @app.call(env)
|
|
150
|
-
request_end =
|
|
150
|
+
request_end = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
151
151
|
|
|
152
152
|
Config.instance.logger.info do
|
|
153
153
|
http_context = CurrentContext.fetch(:http)
|
|
154
|
-
content_length =
|
|
155
|
-
duration_ms = (request_end - request_start) * 1000.0
|
|
154
|
+
content_length = response_content_length(headers)
|
|
155
|
+
duration_ms = ((request_end - request_start) * 1000.0).round(1)
|
|
156
156
|
|
|
157
157
|
http_response = HTTPResponse.new(
|
|
158
158
|
content_length: content_length,
|
|
@@ -216,14 +216,14 @@ module Logtail
|
|
|
216
216
|
}
|
|
217
217
|
end
|
|
218
218
|
|
|
219
|
-
request_start =
|
|
219
|
+
request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
220
220
|
status, headers, body = @app.call(env)
|
|
221
|
-
request_end =
|
|
221
|
+
request_end = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
222
222
|
|
|
223
223
|
Config.instance.logger.info do
|
|
224
224
|
event_body = capture_response_body? ? body : nil
|
|
225
|
-
content_length =
|
|
226
|
-
duration_ms = (request_end - request_start) * 1000.0
|
|
225
|
+
content_length = response_content_length(headers)
|
|
226
|
+
duration_ms = ((request_end - request_start) * 1000.0).round(1)
|
|
227
227
|
|
|
228
228
|
http_response = HTTPResponse.new(
|
|
229
229
|
body: event_body,
|
|
@@ -283,6 +283,12 @@ module Logtail
|
|
|
283
283
|
end.to_h
|
|
284
284
|
end
|
|
285
285
|
|
|
286
|
+
# Rack 3 applications return "content-length", older ones usually "Content-Length".
|
|
287
|
+
def response_content_length(headers)
|
|
288
|
+
_name, value = headers.find { |name, _value| name.to_s.downcase == CONTENT_LENGTH_KEY }
|
|
289
|
+
safe_to_i(value)
|
|
290
|
+
end
|
|
291
|
+
|
|
286
292
|
def safe_to_i(val)
|
|
287
293
|
val.nil? ? nil : val.to_i
|
|
288
294
|
end
|
data/lib/logtail-rack/version.rb
CHANGED