deprecation_collector 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +9 -3
- data/README.md +2 -0
- data/deprecation_collector.gemspec +1 -1
- data/lib/deprecation_collector/deprecation.rb +1 -1
- data/lib/deprecation_collector/version.rb +1 -1
- data/lib/deprecation_collector.rb +27 -17
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f45c8742c0a83f697b04d7a99af54749b354c25cfcffb78f152a680f8224584
|
4
|
+
data.tar.gz: ab25a06b38f3ebfe82a48136c8a58da8d61e4db93614af0c66e283771f0b61b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d395dc4cedb786ab398911e5de19568f44317040352f1b85a6fc45a45fce465d6c82b8092c2f74e0a6b1d18e4dedfbc3284d59767dad2f3a2202143acd969b81
|
7
|
+
data.tar.gz: 0f9a6cd6f02b9b674710db839fcce21f69a2af31a41cc552ad3266b7cd1c3eaa21dac1ac7f94f0208833536e29c20d70e0261e6b087bc548597035c45bc47799
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 0.0.5 (unreleased)
|
2
|
+
- options `print_to_stderr`, `print_recurring`
|
3
|
+
- fix redis deprecated `pipelined` block arity (support for redis 5)
|
4
|
+
|
1
5
|
== 0.0.4
|
2
6
|
- added first_timestamp to deprecations (unix timestamp of first occurrence, not accurate because a worker with later timestamp may dump its deprecations earlier)
|
3
7
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
deprecation_collector (0.0.
|
5
|
-
redis (>=
|
4
|
+
deprecation_collector (0.0.5)
|
5
|
+
redis (>= 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -84,8 +84,12 @@ GEM
|
|
84
84
|
nokogiri (~> 1)
|
85
85
|
rake
|
86
86
|
mini_mime (1.1.2)
|
87
|
+
mini_portile2 (2.8.0)
|
87
88
|
minitest (5.15.0)
|
88
89
|
nio4r (2.5.8)
|
90
|
+
nokogiri (1.13.6)
|
91
|
+
mini_portile2 (~> 2.8.0)
|
92
|
+
racc (~> 1.4)
|
89
93
|
nokogiri (1.13.6-x86_64-darwin)
|
90
94
|
racc (~> 1.4)
|
91
95
|
parallel (1.22.1)
|
@@ -123,7 +127,7 @@ GEM
|
|
123
127
|
thor (>= 0.20.3, < 2.0)
|
124
128
|
rainbow (3.1.1)
|
125
129
|
rake (13.0.6)
|
126
|
-
redis (4.
|
130
|
+
redis (4.8.0)
|
127
131
|
regexp_parser (2.5.0)
|
128
132
|
rexml (3.2.5)
|
129
133
|
rspec (3.11.0)
|
@@ -181,12 +185,14 @@ GEM
|
|
181
185
|
zeitwerk (2.5.4)
|
182
186
|
|
183
187
|
PLATFORMS
|
188
|
+
ruby
|
184
189
|
x86_64-darwin-21
|
185
190
|
|
186
191
|
DEPENDENCIES
|
187
192
|
deprecation_collector!
|
188
193
|
rails (= 6.0)
|
189
194
|
rake (~> 13.0)
|
195
|
+
redis (~> 4.8)
|
190
196
|
rspec (~> 3.0)
|
191
197
|
rubocop (~> 1.21)
|
192
198
|
rubocop-performance
|
data/README.md
CHANGED
@@ -28,6 +28,8 @@ Add an initializer with configuration, like
|
|
28
28
|
instance.raise_on_deprecation = false
|
29
29
|
instance.write_interval = (::Rails.env.production? && 15.minutes) || 1.minute
|
30
30
|
instance.exclude_realms = %i[kernel] if Rails.env.production?
|
31
|
+
instance.print_to_stderr = true if Rails.env.development?
|
32
|
+
instance.print_recurring = false
|
31
33
|
instance.ignored_messages = [
|
32
34
|
"Ignoring db/schema_cache.yml because it has expired"
|
33
35
|
]
|
@@ -54,7 +54,7 @@ class DeprecationCollector
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def digest_base
|
57
|
-
"1:#{RUBY_VERSION}:#{Rails.version}:#{message_for_digest}:#{gem_traceline}:#{app_traceline}"
|
57
|
+
"1:#{RUBY_VERSION}:#{defined?(Rails) && Rails.version}:#{message_for_digest}:#{gem_traceline}:#{app_traceline}"
|
58
58
|
end
|
59
59
|
|
60
60
|
def as_json(_options = {})
|
@@ -54,7 +54,8 @@ class DeprecationCollector
|
|
54
54
|
attr_accessor :count, :raise_on_deprecation, :save_full_backtrace,
|
55
55
|
:exclude_realms,
|
56
56
|
:write_interval, :write_interval_jitter,
|
57
|
-
:app_revision, :app_root
|
57
|
+
:app_revision, :app_root,
|
58
|
+
:print_to_stderr, :print_recurring
|
58
59
|
attr_writer :redis
|
59
60
|
|
60
61
|
def initialize(mutex: nil)
|
@@ -97,8 +98,8 @@ class DeprecationCollector
|
|
97
98
|
raise "Deprecation: #{message}" if @raise_on_deprecation
|
98
99
|
|
99
100
|
deprecation = Deprecation.new(message, realm, backtrace, cleanup_prefixes)
|
100
|
-
store_deprecation(deprecation)
|
101
|
-
log_deprecation_if_needed(deprecation)
|
101
|
+
fresh = store_deprecation(deprecation)
|
102
|
+
log_deprecation_if_needed(deprecation, fresh)
|
102
103
|
end
|
103
104
|
|
104
105
|
def unsent_data?
|
@@ -190,10 +191,10 @@ class DeprecationCollector
|
|
190
191
|
def read_one(digest)
|
191
192
|
decode_deprecation(
|
192
193
|
digest,
|
193
|
-
*@redis.pipelined do
|
194
|
-
|
195
|
-
|
196
|
-
|
194
|
+
*@redis.pipelined do |pipe|
|
195
|
+
pipe.hget("deprecations:data", digest)
|
196
|
+
pipe.hget("deprecations:counter", digest)
|
197
|
+
pipe.hget("deprecations:notes", digest)
|
197
198
|
end
|
198
199
|
)
|
199
200
|
end
|
@@ -201,10 +202,10 @@ class DeprecationCollector
|
|
201
202
|
def delete_deprecations(remove_digests)
|
202
203
|
return 0 unless remove_digests.any?
|
203
204
|
|
204
|
-
@redis.pipelined do
|
205
|
-
|
206
|
-
|
207
|
-
|
205
|
+
@redis.pipelined do |pipe|
|
206
|
+
pipe.hdel("deprecations:data", *remove_digests)
|
207
|
+
pipe.hdel("deprecations:notes", *remove_digests)
|
208
|
+
pipe.hdel("deprecations:counter", *remove_digests) if @count
|
208
209
|
end.first
|
209
210
|
end
|
210
211
|
|
@@ -226,18 +227,22 @@ class DeprecationCollector
|
|
226
227
|
|
227
228
|
def store_deprecation(deprecation)
|
228
229
|
return if deprecation.ignored?
|
230
|
+
fresh = !@deprecations.key?(deprecation.digest)
|
229
231
|
|
230
232
|
@deprecations_mutex.synchronize do
|
231
233
|
(@deprecations[deprecation.digest] ||= deprecation).touch
|
232
234
|
end
|
233
235
|
|
234
236
|
write_to_redis if current_time - @last_write_time > (@write_interval + rand(@write_interval_jitter))
|
237
|
+
fresh
|
235
238
|
end
|
236
239
|
|
237
|
-
def log_deprecation_if_needed(deprecation)
|
238
|
-
return unless
|
239
|
-
|
240
|
-
|
240
|
+
def log_deprecation_if_needed(deprecation, fresh)
|
241
|
+
return unless print_to_stderr && !deprecation.ignored?
|
242
|
+
return unless fresh || print_recurring
|
243
|
+
msg = deprecation.message
|
244
|
+
msg = "DEPRECATION: #{msg}" unless msg.start_with?('DEPRECAT')
|
245
|
+
$stderr.puts(msg) # rubocop:disable Style/StderrPuts
|
241
246
|
end
|
242
247
|
|
243
248
|
def current_time
|
@@ -247,7 +252,12 @@ class DeprecationCollector
|
|
247
252
|
end
|
248
253
|
|
249
254
|
def decode_deprecation(digest, data, count, notes)
|
255
|
+
return nil unless data
|
250
256
|
data = JSON.parse(data, symbolize_names: true)
|
257
|
+
unless data.is_a?(Hash)
|
258
|
+
binding.irb
|
259
|
+
return nil
|
260
|
+
end
|
251
261
|
data[:digest] = digest
|
252
262
|
data[:notes] = JSON.parse(notes, symbolize_names: true) if notes
|
253
263
|
data[:count] = count.to_i if count
|
@@ -255,9 +265,9 @@ class DeprecationCollector
|
|
255
265
|
end
|
256
266
|
|
257
267
|
def write_count_to_redis(deprecations_to_flush)
|
258
|
-
@redis.pipelined do
|
268
|
+
@redis.pipelined do |pipe|
|
259
269
|
deprecations_to_flush.each_pair do |digest, deprecation|
|
260
|
-
|
270
|
+
pipe.hincrby("deprecations:counter", digest, deprecation.occurences)
|
261
271
|
end
|
262
272
|
end
|
263
273
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deprecation_collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasily Fedoseyev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
description: Collects and aggregates warnings and deprecations. Optimized for production
|
28
28
|
environment.
|
29
29
|
email:
|
@@ -54,7 +54,7 @@ metadata:
|
|
54
54
|
homepage_uri: https://github.com/Vasfed/deprecation_collector
|
55
55
|
source_code_uri: https://github.com/Vasfed/deprecation_collector
|
56
56
|
changelog_uri: https://github.com/Vasfed/deprecation_collector/blob/main/CHANGELOG.md
|
57
|
-
post_install_message:
|
57
|
+
post_install_message:
|
58
58
|
rdoc_options: []
|
59
59
|
require_paths:
|
60
60
|
- lib
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubygems_version: 3.1.6
|
73
|
-
signing_key:
|
73
|
+
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Collector for ruby/rails deprecations and warnings, suitable for production
|
76
76
|
test_files: []
|