deprecation_collector 0.0.5 → 0.0.6

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: 6f45c8742c0a83f697b04d7a99af54749b354c25cfcffb78f152a680f8224584
4
- data.tar.gz: ab25a06b38f3ebfe82a48136c8a58da8d61e4db93614af0c66e283771f0b61b7
3
+ metadata.gz: edc00d8d4dd22e076dd0c331bd65ee2a6caad48e28ee0f2a79253f94d6d5a1b3
4
+ data.tar.gz: a8d0a71ada4d0eae355f853f685ea4548124e5090bcac361bb4363ef69b8faaa
5
5
  SHA512:
6
- metadata.gz: d395dc4cedb786ab398911e5de19568f44317040352f1b85a6fc45a45fce465d6c82b8092c2f74e0a6b1d18e4dedfbc3284d59767dad2f3a2202143acd969b81
7
- data.tar.gz: 0f9a6cd6f02b9b674710db839fcce21f69a2af31a41cc552ad3266b7cd1c3eaa21dac1ac7f94f0208833536e29c20d70e0261e6b087bc548597035c45bc47799
6
+ metadata.gz: b7f467b251d4e04f9d23f5524f1c0e36d6ab363090664178ef82d78d261e118d7f30511f6711ebde8205cde3fe46e871f870752c8be867f4f0bd743344589e5b
7
+ data.tar.gz: 2c3b8f59fc2adb43a04a39f3fb39f02bcd752ebbc9d7a1974a77a8441dfeb1daaf65ec87704d7159a1b31a443c20df5a202ff1872e08a28e709baccd84657998
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
- == 0.0.5 (unreleased)
1
+ == 0.0.6
2
+ - added custom context saving ability
3
+
4
+ == 0.0.5
2
5
  - options `print_to_stderr`, `print_recurring`
3
6
  - fix redis deprecated `pipelined` block arity (support for redis 5)
4
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_collector (0.0.5)
4
+ deprecation_collector (0.0.6)
5
5
  redis (>= 3.0)
6
6
 
7
7
  GEM
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DeprecationCollector
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
@@ -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.5
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-09-02 00:00:00.000000000 Z
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.1.6
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: []