lorekeeper 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8099634bb3a3f3d4d348737b0c9634a3a70743c1d868ebec42c194865df7a13c
4
- data.tar.gz: c216efb9f7f6c2e06c357aee59d1f0ad8299445c5becc0d8fc4f2d444e5193ec
3
+ metadata.gz: b28b160e67e8d9321eebfb99ba3ade77f7409633ae3977b43abe5cdcdf62cb15
4
+ data.tar.gz: d2446915f9a3dd36ce5051316557816b884b33ea7ebbb3a3eeac8cb96ce528fc
5
5
  SHA512:
6
- metadata.gz: 93af9f7d3142bdc8166a14e2324b71fe3e51c3f150ea2fccee8557fc2d17b92517b3d6214e8021ed86bdbf632bed836b12027bf438f4bba0099ef1bbaed32e63
7
- data.tar.gz: d81128b6905c1f70e7946bf7be63bf35923d40056d9c9ab7274397b7ff8726da582109f83c0c2905768c0c694ac48c2fa8574dd894f10a0b60d6c3b0ac28dfbb
6
+ metadata.gz: 23d9b597ad2cc8cd4a5bc411f63a70f30930c066289aa17258319ddb8e9fdd68f092d8706ace0f5ce468e4ebfe4c8037b67007cb7e3accdf4489f11c6647dc11
7
+ data.tar.gz: 482721d054b7631906058eacf6c07db16235964ab7cf658e49ba92e8ed979beb05223240284d72267fe694aec6e66a576769bb862bfeba9d9f8ccf834e8d8187
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 2.5.0
2
+ * Update the backtrace cleaner in JSONLogger to remove web server and stdlib lines, and to strip the Rails.root prefix
3
+
1
4
  # 2.4.0
2
5
  * Add `#with_level` method support added to the stdlib's Logger in [#85](https://github.com/ruby/logger/issues/85)
3
6
  * Support symbol log level setting
data/README.md CHANGED
@@ -20,6 +20,15 @@ bundle
20
20
  ```
21
21
 
22
22
 
23
+ ## Configuration
24
+
25
+ Configuration is set through environment variables.
26
+
27
+ - `LOREKEEPER_DENYLIST`
28
+ - A comma separated list of keywords/phrases that will be excluded from the clean backtrace.
29
+ - default: `newrelic_rpm, active_support/callbacks.rb, zipkin-tracer, puma, phusion_passenger, opentelemetry`
30
+
31
+
23
32
  ## Usage
24
33
 
25
34
  ### Normal logging methods
data/bin/console CHANGED
File without changes
data/bin/setup CHANGED
File without changes
@@ -10,6 +10,11 @@ module Lorekeeper
10
10
  reset_state
11
11
  @base_fields = { TIMESTAMP => '', MESSAGE => '', LEVEL => '' }
12
12
  @backtrace_cleaner = set_backtrace_cleaner
13
+ @rails_root = defined?(Rails.root) ? Rails.root.to_s : nil
14
+ @rails_root_size = @rails_root.to_s.size
15
+ @gem_path = defined?(Gem.path) ? Gem.path : []
16
+ @denylisted_fingerprint = denylisted_fingerprint
17
+
13
18
  super(file)
14
19
  end
15
20
 
@@ -113,18 +118,38 @@ module Lorekeeper
113
118
 
114
119
  # Some instrumentation libraries pollute the stacktrace and create a large output which may
115
120
  # cause problems with certain logging backends.
116
- # Hardcording newrelic, active_support/callbacks and zipkin-tracer now here.
117
- # In the future if this list grows, we may make it configurable.
121
+ # Cleaner defaults to newrelic, active_support/callbacks, zipkin-tracer, opentelemetry, web servers,
122
+ # and stdlib now but can be configured by using LOREKEEPER_DENYLIST env var.
118
123
  def clean_backtrace(backtrace)
124
+ backtrace = filter_rails_root_backtrace(backtrace)
119
125
  @backtrace_cleaner&.clean(backtrace) || backtrace
120
126
  end
121
127
 
128
+ def filter_rails_root_backtrace(backtrace)
129
+ return backtrace unless @rails_root
130
+
131
+ last_index = nil
132
+ result = []
133
+ backtrace.each_with_index do |line, idx|
134
+ if line.start_with?(@rails_root) && @gem_path.none? { |path| line.start_with?(path) }
135
+ result << line[@rails_root_size..]
136
+ last_index = idx
137
+ else
138
+ result << line
139
+ end
140
+ end
141
+
142
+ last_index ? result[..last_index] : result
143
+ end
144
+
122
145
  def set_backtrace_cleaner
123
146
  return nil unless defined?(ActiveSupport::BacktraceCleaner)
124
147
 
125
148
  cleaner = ActiveSupport::BacktraceCleaner.new
126
149
  cleaner.remove_silencers!
127
- cleaner.add_silencer { |line| line.match?(BLACKLISTED_FINGERPRINT) }
150
+ cleaner.add_silencer do |line|
151
+ line.match?(@denylisted_fingerprint) || line.start_with?(RbConfig::CONFIG['rubylibdir'])
152
+ end
128
153
  cleaner
129
154
  end
130
155
 
@@ -136,7 +161,14 @@ module Lorekeeper
136
161
  EXCEPTION = 'exception'
137
162
  STACK = 'stack'
138
163
  DATA = 'data'
139
- BLACKLISTED_FINGERPRINT = %r{newrelic_rpm|active_support/callbacks.rb|zipkin-tracer}.freeze
164
+ DENYLISTED_FINGERPRINT =
165
+ %r{newrelic_rpm|active_support/callbacks.rb|zipkin-tracer|puma|phusion_passenger|opentelemetry}.freeze
166
+
167
+ def denylisted_fingerprint
168
+ return DENYLISTED_FINGERPRINT unless ENV.key?('LOREKEEPER_DENYLIST')
169
+
170
+ /#{ENV.fetch('LOREKEEPER_DENYLIST').split(',').map(&:strip).join('|')}/
171
+ end
140
172
 
141
173
  def with_extra_fields(fields)
142
174
  state[:extra_fields] = fields
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lorekeeper
4
- VERSION = '2.4.0'
4
+ VERSION = '2.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lorekeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordi Polo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-06 00:00:00.000000000 Z
11
+ date: 2023-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -233,7 +233,7 @@ homepage: https://github.com/JordiPolo/lorekeeper
233
233
  licenses:
234
234
  - MIT
235
235
  metadata: {}
236
- post_install_message:
236
+ post_install_message:
237
237
  rdoc_options: []
238
238
  require_paths:
239
239
  - lib
@@ -248,8 +248,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  - !ruby/object:Gem::Version
249
249
  version: '0'
250
250
  requirements: []
251
- rubygems_version: 3.0.3.1
252
- signing_key:
251
+ rubygems_version: 3.2.15
252
+ signing_key:
253
253
  specification_version: 4
254
254
  summary: Very fast JSON logger
255
255
  test_files: []