sentry-ruby 5.12.0 → 5.13.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: 857c6d99b1c5d9378a2522ffa1e466f91869500ae425f9d1add4aae399f1852c
4
- data.tar.gz: 726793c0ae09ce3b137cdc7f48f6745c55176a83c8f651b8b493ee5d1290b522
3
+ metadata.gz: 1d89549da043b049e2dd6f5c73ac6ec0c3dd98ded247be2035316e45110bde88
4
+ data.tar.gz: 38844c5d5521bcf40a749d77667e91fa5b819d98951e4a02ebc807724b91c3a9
5
5
  SHA512:
6
- metadata.gz: 13ccb78050835c829d738550bc9838347c71abc2139089c29ab466796059259740207d21504bee7cc6f4ca07dbcc982e12be05ebc0b955a4274a4a30bd0470ee
7
- data.tar.gz: d6b4edd6c562b787b9fe652b6ba6ddb3bf16bca937bacbd22fcc44be746643a77e3595460263f72e3e76e73a7b92ff09577d7c665cfac2520886c3a62a62a2ab
6
+ metadata.gz: 1cc2ac4f8394b8dcafd30d2aa4bbd863e313a04953d5b072997783c54fa76285bff16b77e23ca7f6b22644f9d1a69ad2484c844b7e6bf6deefbf3cbcd874ffbf
7
+ data.tar.gz: c30a0fd380e11f93edc599320a3884464e9d0568327512e514d1586f120b217091f67912531167738efb64ffd55cec960c6083dc894556796a00f2f5c79e13f9
data/README.md CHANGED
@@ -33,7 +33,7 @@ If you're using `sentry-raven`, we recommend you to migrate to this new SDK. You
33
33
 
34
34
  ## Requirements
35
35
 
36
- We test on Ruby 2.4, 2.5, 2.6, 2.7, 3.0, and 3.1 at the latest patchlevel/teeny version. We also support JRuby 9.0.
36
+ We test from Ruby 2.4 to Ruby 3.2 at the latest patchlevel/teeny version. We also support JRuby 9.0.
37
37
 
38
38
  If you use self-hosted Sentry, please also make sure its version is above `20.6.0`.
39
39
 
@@ -9,7 +9,7 @@ module Sentry
9
9
  # @return [Hash, nil]
10
10
  attr_accessor :data
11
11
  # @return [String, nil]
12
- attr_accessor :level
12
+ attr_reader :level
13
13
  # @return [Time, Integer, nil]
14
14
  attr_accessor :timestamp
15
15
  # @return [String, nil]
@@ -26,10 +26,10 @@ module Sentry
26
26
  def initialize(category: nil, data: nil, message: nil, timestamp: nil, level: nil, type: nil)
27
27
  @category = category
28
28
  @data = data || {}
29
- @level = level
30
29
  @timestamp = timestamp || Sentry.utc_now.to_i
31
30
  @type = type
32
31
  self.message = message
32
+ self.level = level
33
33
  end
34
34
 
35
35
  # @return [Hash]
@@ -50,6 +50,12 @@ module Sentry
50
50
  @message = (message || "").byteslice(0..Event::MAX_MESSAGE_SIZE_IN_BYTES)
51
51
  end
52
52
 
53
+ # @param level [String]
54
+ # @return [void]
55
+ def level=(level) # needed to meet the Sentry spec
56
+ @level = level == "warn" ? "warning" : level
57
+ end
58
+
53
59
  private
54
60
 
55
61
  def serialized_data
@@ -1,4 +1,4 @@
1
- # frozen_string_literal
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'securerandom'
4
4
  require 'sentry/cron/monitor_config'
@@ -258,6 +258,11 @@ module Sentry
258
258
  # @return [Float, nil]
259
259
  attr_reader :profiles_sample_rate
260
260
 
261
+ # Array of patches to apply.
262
+ # Default is {DEFAULT_PATCHES}
263
+ # @return [Array<Symbol>]
264
+ attr_accessor :enabled_patches
265
+
261
266
  # these are not config options
262
267
  # @!visibility private
263
268
  attr_reader :errors, :gem_specs
@@ -297,6 +302,8 @@ module Sentry
297
302
 
298
303
  PROPAGATION_TARGETS_MATCH_ALL = /.*/.freeze
299
304
 
305
+ DEFAULT_PATCHES = %i(redis puma http).freeze
306
+
300
307
  class << self
301
308
  # Post initialization callbacks are called at the end of initialization process
302
309
  # allowing extending the configuration of sentry-ruby by multiple extensions
@@ -340,6 +347,7 @@ module Sentry
340
347
  self.server_name = server_name_from_env
341
348
  self.instrumenter = :sentry
342
349
  self.trace_propagation_targets = [PROPAGATION_TARGETS_MATCH_ALL]
350
+ self.enabled_patches = DEFAULT_PATCHES.dup
343
351
 
344
352
  self.before_send = nil
345
353
  self.before_send_transaction = nil
@@ -1,4 +1,4 @@
1
- # frozen_string_literal
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'sentry/cron/monitor_schedule'
4
4
 
@@ -1,4 +1,4 @@
1
- # frozen_string_literal
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
4
  module Cron
@@ -99,4 +99,4 @@ module Sentry
99
99
  end
100
100
  end
101
101
 
102
- Sentry.register_patch(Sentry::Net::HTTP, Net::HTTP)
102
+ Sentry.register_patch(:http, Sentry::Net::HTTP, Net::HTTP)
@@ -109,7 +109,7 @@ module Sentry
109
109
  }
110
110
 
111
111
  frame_hash[:module] = mod if mod
112
- frame_hash[:lineno] = frame_data[:line] if frame_data[:line]
112
+ frame_hash[:lineno] = frame_data[:line] if frame_data[:line] && frame_data[:line] >= 0
113
113
 
114
114
  frame_hash
115
115
  end
data/lib/sentry/puma.rb CHANGED
@@ -1,10 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ return unless defined?(Puma::Server)
4
+
3
5
  module Sentry
4
6
  module Puma
5
7
  module Server
8
+ PUMA_4_AND_PRIOR = Gem::Version.new(::Puma::Const::PUMA_VERSION) < Gem::Version.new("5.0.0")
9
+
6
10
  def lowlevel_error(e, env, status=500)
7
- result = super
11
+ result =
12
+ if PUMA_4_AND_PRIOR
13
+ super(e, env)
14
+ else
15
+ super
16
+ end
8
17
 
9
18
  begin
10
19
  Sentry.capture_exception(e) do |scope|
@@ -20,6 +29,4 @@ module Sentry
20
29
  end
21
30
  end
22
31
 
23
- if defined?(Puma::Server)
24
- Sentry.register_patch(Sentry::Puma::Server, Puma::Server)
25
- end
32
+ Sentry.register_patch(:puma, Sentry::Puma::Server, Puma::Server)
data/lib/sentry/redis.rb CHANGED
@@ -99,8 +99,10 @@ end
99
99
 
100
100
  if defined?(::Redis::Client)
101
101
  if Gem::Version.new(::Redis::VERSION) < Gem::Version.new("5.0")
102
- Sentry.register_patch(Sentry::Redis::OldClientPatch, ::Redis::Client)
102
+ Sentry.register_patch(:redis, Sentry::Redis::OldClientPatch, ::Redis::Client)
103
103
  elsif defined?(RedisClient)
104
- RedisClient.register(Sentry::Redis::GlobalRedisInstrumentation)
104
+ Sentry.register_patch(:redis) do
105
+ RedisClient.register(Sentry::Redis::GlobalRedisInstrumentation)
106
+ end
105
107
  end
106
108
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
- VERSION = "5.12.0"
4
+ VERSION = "5.13.0"
5
5
  end
data/lib/sentry-ruby.rb CHANGED
@@ -75,15 +75,15 @@ module Sentry
75
75
  ##### Patch Registration #####
76
76
 
77
77
  # @!visibility private
78
- def register_patch(patch = nil, target = nil, &block)
78
+ def register_patch(key, patch = nil, target = nil, &block)
79
79
  if patch && block
80
80
  raise ArgumentError.new("Please provide either a patch and its target OR a block, but not both")
81
81
  end
82
82
 
83
83
  if block
84
- registered_patches << block
84
+ registered_patches[key] = block
85
85
  else
86
- registered_patches << proc do
86
+ registered_patches[key] = proc do
87
87
  target.send(:prepend, patch) unless target.ancestors.include?(patch)
88
88
  end
89
89
  end
@@ -91,14 +91,14 @@ module Sentry
91
91
 
92
92
  # @!visibility private
93
93
  def apply_patches(config)
94
- registered_patches.each do |patch|
95
- patch.call(config)
94
+ registered_patches.each do |key, patch|
95
+ patch.call(config) if config.enabled_patches.include?(key)
96
96
  end
97
97
  end
98
98
 
99
99
  # @!visibility private
100
100
  def registered_patches
101
- @registered_patches ||= []
101
+ @registered_patches ||= {}
102
102
  end
103
103
 
104
104
  ##### Integrations #####
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.12.0
4
+ version: 5.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-10 00:00:00.000000000 Z
11
+ date: 2023-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby