deprecation_collector 0.0.5 → 0.0.6
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/CHANGELOG.md +4 -1
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/deprecation_collector/deprecation.rb +3 -1
- data/lib/deprecation_collector/version.rb +1 -1
- data/lib/deprecation_collector.rb +9 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edc00d8d4dd22e076dd0c331bd65ee2a6caad48e28ee0f2a79253f94d6d5a1b3
|
4
|
+
data.tar.gz: a8d0a71ada4d0eae355f853f685ea4548124e5090bcac361bb4363ef69b8faaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f467b251d4e04f9d23f5524f1c0e36d6ab363090664178ef82d78d261e118d7f30511f6711ebde8205cde3fe46e871f870752c8be867f4f0bd743344589e5b
|
7
|
+
data.tar.gz: 2c3b8f59fc2adb43a04a39f3fb39f02bcd752ebbc9d7a1974a77a8441dfeb1daaf65ec87704d7159a1b31a443c20df5a202ff1872e08a28e709baccd84657998
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -33,6 +33,10 @@ Add an initializer with configuration, like
|
|
33
33
|
instance.ignored_messages = [
|
34
34
|
"Ignoring db/schema_cache.yml because it has expired"
|
35
35
|
]
|
36
|
+
instance.context_saver do
|
37
|
+
# this will only be called for new deprecations, return value must be json-compatible
|
38
|
+
{ some: "custom", context: "for example request.id" }
|
39
|
+
end
|
36
40
|
end
|
37
41
|
end
|
38
42
|
```
|
@@ -4,6 +4,7 @@ class DeprecationCollector
|
|
4
4
|
# :nodoc:
|
5
5
|
class Deprecation
|
6
6
|
attr_reader :message, :realm, :gem_traceline, :app_traceline, :occurences, :first_timestamp, :full_backtrace
|
7
|
+
attr_accessor :context
|
7
8
|
|
8
9
|
CLEANUP_REGEXES = {
|
9
10
|
# rails views generated methods names are unique per-worker
|
@@ -70,7 +71,8 @@ class DeprecationCollector
|
|
70
71
|
revision: DeprecationCollector.instance.app_revision,
|
71
72
|
count: @occurences, # output anyway for frequency estimation (during write_interval inside single process)
|
72
73
|
first_timestamp: first_timestamp, # this may not be accurate, a worker with later timestamp may dump earlier
|
73
|
-
digest_base: digest_base # for debug purposes
|
74
|
+
digest_base: digest_base, # for debug purposes
|
75
|
+
context: context
|
74
76
|
}.compact
|
75
77
|
end
|
76
78
|
|
@@ -56,7 +56,7 @@ class DeprecationCollector
|
|
56
56
|
:write_interval, :write_interval_jitter,
|
57
57
|
:app_revision, :app_root,
|
58
58
|
:print_to_stderr, :print_recurring
|
59
|
-
attr_writer :redis
|
59
|
+
attr_writer :redis, :context_saver
|
60
60
|
|
61
61
|
def initialize(mutex: nil)
|
62
62
|
# on cruby hash itself is threadsafe, but we need to prevent races
|
@@ -79,12 +79,19 @@ class DeprecationCollector
|
|
79
79
|
# NB: in production with hugreds of workers may easily overload redis with writes, so more delay needed:
|
80
80
|
@write_interval = 900 # 15.minutes
|
81
81
|
@write_interval_jitter = 60
|
82
|
+
@context_saver = nil
|
82
83
|
end
|
83
84
|
|
84
85
|
def ignored_messages=(val)
|
85
86
|
@ignore_message_regexp = (val && Regexp.union(val)) || nil
|
86
87
|
end
|
87
88
|
|
89
|
+
def context_saver(&block)
|
90
|
+
return @context_saver unless block_given?
|
91
|
+
|
92
|
+
@context_saver = block
|
93
|
+
end
|
94
|
+
|
88
95
|
def app_root_prefix
|
89
96
|
"#{app_root}/"
|
90
97
|
end
|
@@ -228,6 +235,7 @@ class DeprecationCollector
|
|
228
235
|
def store_deprecation(deprecation)
|
229
236
|
return if deprecation.ignored?
|
230
237
|
fresh = !@deprecations.key?(deprecation.digest)
|
238
|
+
deprecation.context = context_saver.call if context_saver
|
231
239
|
|
232
240
|
@deprecations_mutex.synchronize do
|
233
241
|
(@deprecations[deprecation.digest] ||= deprecation).touch
|
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.6
|
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-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -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
|
@@ -69,8 +69,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
rubygems_version: 3.
|
73
|
-
signing_key:
|
72
|
+
rubygems_version: 3.3.7
|
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: []
|