logcraft 2.0.0 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2256a97ecb30662f543512b9ace85cabe956a49ee4407f0f3575a56ff36055bd
4
- data.tar.gz: 89a522ff6b287c903110b9df445f201a65955a52edf371bd3df125691dfa3482
3
+ metadata.gz: 1553a9ab5e60ffb3beab51543cefcca10632c655fafa559ed18fe123dad9243a
4
+ data.tar.gz: 673ea0771ff8846f9b191f1ab745233cc6002dc2b454b92b97a4e5a8088dea33
5
5
  SHA512:
6
- metadata.gz: 2cefe4bd29be7ccabaedd3503e3d135fa05f95128d939df500d516644d1cb7fab18aaf8a410a1077bf549b345dfa2cf773dee01baba5d941d47e9a95828c14fd
7
- data.tar.gz: 915fcd06110d9e200652d5f9bbe62c3d9a3ee49151e7147df68855d4d58639a3ac7788df74b2ca3c037984c4a5026b2e923494849408731c10584fdae0b0054c
6
+ metadata.gz: d440d1fb9a136f36e30911912ec79fff375ad4086b87697399e6530422d92e8749307ac043acdec270a04d507281e009d5f2bf86f5c01ab00192e40de34149d8
7
+ data.tar.gz: 5a207a0a5ed398a1ecd95db4252cd0455c265f8a93b4b3b22ab7a60f852d2b8b072ee59366117665476fd35730c134aac958b16d2f1c3670bcf538f08773ea97
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.0.1] - 2022-10-07
8
+ ### Fixed
9
+ - Fixed a bug where request log tracing didn't work with the DataDog integration. Had to move up logging
10
+ the request to the point where the middleware is done processing instead of where we originally had it;
11
+ at the time when the response body was closed. We lost some precision in terms of measuring request duration
12
+ but some context (e.g. DataDog active trace) would not be available otherwise.
13
+
7
14
  ## [2.0.0] - 2022-07-31
8
15
  ### Added
9
16
  - Added the option to change the log level or suppress logging of unhandled errors which are, in fact,
data/README.md CHANGED
@@ -274,6 +274,17 @@ ActiveSupport::JSON.encode test: 'foo > bar'
274
274
  I highly recommend using the [Oj](https://github.com/ohler55/oj) gem which - if present - will be automatically
275
275
  picked up by Logcraft, as it is significantly faster and will serialize your messages as you would expect.
276
276
 
277
+ In a nutshell:
278
+ ```ruby
279
+ # With default ActiveSupport serialization
280
+ Rails.logger.info 'foo > bar'
281
+ #=> {...,"message":"foo \u003e bar"}
282
+
283
+ # With Oj
284
+ Rails.logger.info 'foo > bar'
285
+ #=> {...,"message":"foo > bar"}
286
+ ```
287
+
277
288
  ## Configuration options
278
289
 
279
290
  ### Rails configuration
@@ -14,13 +14,9 @@ module Logcraft
14
14
  request = ActionDispatch::Request.new env
15
15
 
16
16
  instrumentation_start request
17
-
18
17
  status, headers, body = @app.call env
19
- request_id = Logging.mdc[:request_id]
20
- body = ::Rack::BodyProxy.new(body) do
21
- instrumentation_finish request
22
- log_request request, status, start_time, request_id
23
- end
18
+ body = ::Rack::BodyProxy.new(body) { instrumentation_finish request }
19
+ log_request request, status, start_time
24
20
 
25
21
  [status, headers, body]
26
22
  rescue Exception => ex
@@ -47,22 +43,18 @@ module Logcraft
47
43
  instrumenter.finish 'request.action_dispatch', request: request
48
44
  end
49
45
 
50
- def log_request(request, status, start_time, request_id = nil)
46
+ def log_request(request, status, start_time)
51
47
  return if path_ignored? request
52
48
 
53
49
  end_time = current_time_in_milliseconds
54
- message = {
55
- message: '%s %s - %i (%s)' % [request.method, request.filtered_path, status, Rack::Utils::HTTP_STATUS_CODES[status]],
56
- remote_ip: request.remote_ip,
57
- method: request.method,
58
- path: request.filtered_path,
59
- params: params_to_log(request),
60
- response_status_code: status,
61
- duration: end_time - start_time,
62
- duration_sec: (end_time - start_time) / 1000.0
63
- }
64
- message[:request_id] = request_id if request_id
65
- @logger.info message
50
+ @logger.info message: '%s %s - %i (%s)' % [request.method, request.filtered_path, status, Rack::Utils::HTTP_STATUS_CODES[status]],
51
+ remote_ip: request.remote_ip,
52
+ method: request.method,
53
+ path: request.filtered_path,
54
+ params: params_to_log(request),
55
+ response_status_code: status,
56
+ duration: end_time - start_time,
57
+ duration_sec: (end_time - start_time) / 1000.0
66
58
  end
67
59
 
68
60
  def path_ignored?(request)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Logcraft
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logcraft
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoltan Ormandi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-31 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
- description:
83
+ description:
84
84
  email:
85
85
  - zoltan.ormandi@gmail.com
86
86
  executables: []
@@ -120,7 +120,7 @@ metadata:
120
120
  homepage_uri: https://github.com/zormandi/logcraft
121
121
  source_code_uri: https://github.com/zormandi/logcraft
122
122
  changelog_uri: https://github.com/zormandi/logcraft/blob/main/CHANGELOG.md
123
- post_install_message:
123
+ post_install_message:
124
124
  rdoc_options: []
125
125
  require_paths:
126
126
  - lib
@@ -135,8 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.1.6
139
- signing_key:
138
+ rubygems_version: 3.3.7
139
+ signing_key:
140
140
  specification_version: 4
141
141
  summary: A zero-configuration structured logging solution for pure Ruby or Ruby on
142
142
  Rails projects.