lib/timber/integrations/rack/http_events.rb in timber-2.4.0 vs lib/timber/integrations/rack/http_events.rb in timber-2.5.0

- old
+ new

@@ -104,10 +104,12 @@ def silence_request @silence_request end end + CONTENT_LENGTH_KEY = 'Content-Length'.freeze + def call(env) request = Util::Request.new(env) if silenced?(env, request) if Config.instance.logger.respond_to?(:silence) @@ -124,13 +126,15 @@ status, headers, body = @app.call(env) Config.instance.logger.info do http_context_key = Contexts::HTTP.keyspace http_context = CurrentContext.fetch(http_context_key) + content_length = headers[CONTENT_LENGTH_KEY] time_ms = (Time.now - start) * 1000.0 Events::HTTPResponse.new( + content_length: content_length, headers: headers, http_context: http_context, request_id: request.request_id, status: status, time_ms: time_ms @@ -145,10 +149,11 @@ Config.instance.logger.info do event_body = capture_request_body? ? request.body_content : nil Events::HTTPRequest.new( body: event_body, + content_length: request.content_length, headers: request.headers, host: request.host, method: request.request_method, path: request.path, port: request.port, @@ -159,14 +164,16 @@ end status, headers, body = @app.call(env) Config.instance.logger.info do - time_ms = (Time.now - start) * 1000.0 event_body = capture_response_body? ? body : nil + content_length = headers[CONTENT_LENGTH_KEY] + time_ms = (Time.now - start) * 1000.0 Events::HTTPResponse.new( body: event_body, + content_length: content_length, headers: headers, request_id: request.request_id, status: status, time_ms: time_ms ) \ No newline at end of file