honeybadger 5.8.1 → 5.9.0

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: 970f861f7385a6b9623cab40cc53b5d12ec7466c45b977bbdaaa6bae7d79a4a3
4
- data.tar.gz: 49c3ce7f9e6b37e77806ea20ddd0372a17e432f08b31f0dd401c3cd56af2be84
3
+ metadata.gz: 2c74b0590c5e22b6e264874c05c3dcc6a05159d9fe9daa119222c3fada7610da
4
+ data.tar.gz: acce276df177dc0c91c15a216c65f9ecd78e9d1221d5f4d39bb1c95bbee4f509
5
5
  SHA512:
6
- metadata.gz: c2446dc5c909c48c799a5fa6b7561b0e4fbf481c16f3ac36f7b0611ee09f842bebc65d39c2bb17897b4125edaead2d4f408b870c101d256f8dafe6797c95cfa6
7
- data.tar.gz: 0b5c84e1eaba9b4b7e3d40dbe0a6d784237d3d76a9354fb041ef58a305c8a4c1362e71d8026dfb9ca30b5683ce82fbfb4109727471d786f624816a43eeb3849d
6
+ metadata.gz: bcac64eba99e9cad7d31d59d31643080b6725f6e32ee9454e8f4ffb7fc354a6b10b03433ca5469d280c6afca7b6d4df0e7c2aaa5edc858124a416c22d3e52da8
7
+ data.tar.gz: 7bfe5cfde348795b66d3fe97ff9e4c7bbe41d1b1fd273b39524d1a225dfebd6dcc62c1dae563fb95c5535362e1f9dbe8f08c8798de516941e433a440258449d3
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log
2
2
 
3
3
 
4
+ ## [5.9.0](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.8.1...v5.9.0) (2024-05-09)
5
+
6
+
7
+ ### Features
8
+
9
+ * implement local contexts ([#541](https://github.com/honeybadger-io/honeybadger-ruby/issues/541)) ([806718e](https://github.com/honeybadger-io/honeybadger-ruby/commit/806718e76bf8d132a632c75bea124a8b22a4cc97))
10
+
4
11
  ## [5.8.1](https://github.com/honeybadger-io/honeybadger-ruby/compare/v5.8.0...v5.8.1) (2024-05-07)
5
12
 
6
13
 
@@ -259,8 +259,8 @@ module Honeybadger
259
259
  # (optional).
260
260
  #
261
261
  # @return [self] so that method calls can be chained.
262
- def context(context = nil)
263
- context_manager.set_context(context) unless context.nil?
262
+ def context(context = nil, &block)
263
+ context_manager.set_context(context, &block) unless context.nil?
264
264
  self
265
265
  end
266
266
 
@@ -21,15 +21,36 @@ module Honeybadger
21
21
  # Internal helpers
22
22
 
23
23
 
24
- def set_context(hash)
24
+ def set_context(hash, &block)
25
+ local = block_given?
25
26
  @mutex.synchronize do
26
- @context ||= {}
27
- @context.update(Context(hash))
27
+ @global_context ||= {}
28
+ @local_context ||= []
29
+
30
+ new_context = Context(hash)
31
+
32
+ if local
33
+ @local_context << new_context
34
+ else
35
+ @global_context.update(new_context)
36
+ end
37
+ end
38
+
39
+ if local
40
+ begin
41
+ yield
42
+ ensure
43
+ @mutex.synchronize { @local_context&.pop }
44
+ end
28
45
  end
29
46
  end
30
47
 
31
48
  def get_context
32
- @mutex.synchronize { @context }
49
+ @mutex.synchronize do
50
+ return @global_context unless @local_context
51
+
52
+ @global_context.merge(@local_context.inject({}, :merge))
53
+ end
33
54
  end
34
55
 
35
56
  def set_rack_env(env)
@@ -46,10 +67,10 @@ module Honeybadger
46
67
 
47
68
  def _initialize
48
69
  @mutex.synchronize do
49
- @context = nil
70
+ @global_context = nil
71
+ @local_context = nil
50
72
  @rack_env = nil
51
73
  end
52
74
  end
53
-
54
75
  end
55
76
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '5.8.1'.freeze
3
+ VERSION = '5.9.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.1
4
+ version: 5.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-07 00:00:00.000000000 Z
11
+ date: 2024-05-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email: