sentry-ruby-core 5.22.1 → 5.22.3

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: f8bbd67a379767b17c92face4aece900b5f559ba676e5531ff30cc7c94b770ec
4
- data.tar.gz: f347cb6245d5d37f2d883870b26d846244d33ef6cbb67b838fe231d1c17e95f8
3
+ metadata.gz: 9f58e301ed4dd9c659dee10a489bc67ec2b3965b721e88842c0749639f751c33
4
+ data.tar.gz: d7758ef8b065a2b772ccebec8eee4807683a002495ca55dab7e85f8c1b92768f
5
5
  SHA512:
6
- metadata.gz: 6b4d0189ef85dc508e12fe28642037e38f87dae95039586b4f6369e4ba45526601a5b9e9e9bfe79dc0ec20deb14a1b6f6b7f4cd04b07b379ca654d6f1ba24b14
7
- data.tar.gz: b17875017e20c0126c8ddc5d360873430c92d69f0633134743198140c2258f828b3b444748c7a4cd8e0bb9137a9990f2dc394182ffcfe6a19d1e0f3795beebcd
6
+ metadata.gz: 71cb5b8076d2d4015e3a078ddeb68457460578fa9466fa9d87da55863436ac17ff62e8d6ad78518fc4217950862e39302ab85db2f2835f6729b3fb47b3929a99
7
+ data.tar.gz: 5f6777c874b1544eab2e47359d61d1eb6cd725b6f1788e2595815e8340d1291e7da7632373c77635ebe717e8c75537a9157a0a904a90bdc1b518fb9819adb0e8
data/Gemfile CHANGED
@@ -9,6 +9,8 @@ rack_version = ENV["RACK_VERSION"]
9
9
  rack_version = "3.0.0" if rack_version.nil?
10
10
  gem "rack", "~> #{Gem::Version.new(rack_version)}" unless rack_version == "0"
11
11
 
12
+ gem "ostruct" if RUBY_VERSION >= "3.4"
13
+
12
14
  redis_rb_version = ENV.fetch("REDIS_RB_VERSION", "5.0")
13
15
  gem "redis", "~> #{redis_rb_version}"
14
16
 
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 from Ruby 2.4 to Ruby 3.2 at the latest patchlevel/teeny version. We also support JRuby 9.0.
36
+ We test from Ruby 2.4 to Ruby 3.4 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
 
@@ -12,7 +12,7 @@ module Sentry
12
12
  RUBY_INPUT_FORMAT = /
13
13
  ^ \s* (?: [a-zA-Z]: | uri:classloader: )? ([^:]+ | <.*>):
14
14
  (\d+)
15
- (?: :in\s('|`)([^']+)')?$
15
+ (?: :in\s('|`)(?:([\w:]+)\#)?([^']+)')?$
16
16
  /x
17
17
 
18
18
  # org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
@@ -37,10 +37,11 @@ module Sentry
37
37
  # @return [Line] The parsed backtrace line
38
38
  def self.parse(unparsed_line, in_app_pattern = nil)
39
39
  ruby_match = unparsed_line.match(RUBY_INPUT_FORMAT)
40
+
40
41
  if ruby_match
41
- _, file, number, _, method = ruby_match.to_a
42
+ _, file, number, _, module_name, method = ruby_match.to_a
42
43
  file.sub!(/\.class$/, RB_EXTENSION)
43
- module_name = nil
44
+ module_name = module_name
44
45
  else
45
46
  java_match = unparsed_line.match(JAVA_INPUT_FORMAT)
46
47
  _, module_name, method, file, number = java_match.to_a
data/lib/sentry/client.rb CHANGED
@@ -183,8 +183,19 @@ module Sentry
183
183
  if event_type != TransactionEvent::TYPE && configuration.before_send
184
184
  event = configuration.before_send.call(event, hint)
185
185
 
186
- if event.nil?
187
- log_debug("Discarded event because before_send returned nil")
186
+ case event
187
+ when ErrorEvent
188
+ # do nothing
189
+ when Hash
190
+ log_debug(<<~MSG)
191
+ Returning a Hash from before_send is deprecated and will be removed in the next major version.
192
+ Please return a Sentry::ErrorEvent object instead.
193
+ MSG
194
+ else
195
+ # Avoid serializing the event object in this case because we aren't sure what it is and what it contains
196
+ log_debug(<<~MSG)
197
+ Discarded event because before_send didn't return a Sentry::ErrorEvent object but an instance of #{event.class}
198
+ MSG
188
199
  transport.record_lost_event(:before_send, data_category)
189
200
  return
190
201
  end
@@ -193,15 +204,25 @@ module Sentry
193
204
  if event_type == TransactionEvent::TYPE && configuration.before_send_transaction
194
205
  event = configuration.before_send_transaction.call(event, hint)
195
206
 
196
- if event.nil?
197
- log_debug("Discarded event because before_send_transaction returned nil")
198
- transport.record_lost_event(:before_send, "transaction")
199
- transport.record_lost_event(:before_send, "span", num: spans_before + 1)
200
- return
201
- else
207
+ if event.is_a?(TransactionEvent) || event.is_a?(Hash)
202
208
  spans_after = event.is_a?(TransactionEvent) ? event.spans.size : 0
203
209
  spans_delta = spans_before - spans_after
204
210
  transport.record_lost_event(:before_send, "span", num: spans_delta) if spans_delta > 0
211
+
212
+ if event.is_a?(Hash)
213
+ log_debug(<<~MSG)
214
+ Returning a Hash from before_send_transaction is deprecated and will be removed in the next major version.
215
+ Please return a Sentry::TransactionEvent object instead.
216
+ MSG
217
+ end
218
+ else
219
+ # Avoid serializing the event object in this case because we aren't sure what it is and what it contains
220
+ log_debug(<<~MSG)
221
+ Discarded event because before_send_transaction didn't return a Sentry::TransactionEvent object but an instance of #{event.class}
222
+ MSG
223
+ transport.record_lost_event(:before_send, "transaction")
224
+ transport.record_lost_event(:before_send, "span", num: spans_before + 1)
225
+ return
205
226
  end
206
227
  end
207
228
 
@@ -14,12 +14,12 @@ module Sentry
14
14
  :in_progress,
15
15
  monitor_config: monitor_config)
16
16
 
17
- start = Sentry.utc_now.to_i
17
+ start = Metrics::Timing.duration_start
18
18
 
19
19
  begin
20
20
  # need to do this on ruby <= 2.6 sadly
21
21
  ret = method(:perform).super_method.arity == 0 ? super() : super
22
- duration = Sentry.utc_now.to_i - start
22
+ duration = Metrics::Timing.duration_end(start)
23
23
 
24
24
  Sentry.capture_check_in(slug,
25
25
  :ok,
@@ -29,7 +29,7 @@ module Sentry
29
29
 
30
30
  ret
31
31
  rescue Exception
32
- duration = Sentry.utc_now.to_i - start
32
+ duration = Metrics::Timing.duration_end(start)
33
33
 
34
34
  Sentry.capture_check_in(slug,
35
35
  :error,
@@ -37,6 +37,14 @@ module Sentry
37
37
  def week
38
38
  Sentry.utc_now.to_i / (3600.0 * 24.0 * 7.0)
39
39
  end
40
+
41
+ def duration_start
42
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
43
+ end
44
+
45
+ def duration_end(start)
46
+ Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
47
+ end
40
48
  end
41
49
  end
42
50
  end
@@ -13,6 +13,7 @@ module Sentry
13
13
  OP_NAME = "http.client"
14
14
  SPAN_ORIGIN = "auto.http.net_http"
15
15
  BREADCRUMB_CATEGORY = "net.http"
16
+ URI_PARSER = URI.const_defined?("RFC2396_PARSER") ? URI::RFC2396_PARSER : URI::DEFAULT_PARSER
16
17
 
17
18
  # To explain how the entire thing works, we need to know how the original Net::HTTP#request works
18
19
  # Here's part of its definition. As you can see, it usually calls itself inside a #start block
@@ -66,7 +67,7 @@ module Sentry
66
67
  # IPv6 url could look like '::1/path', and that won't parse without
67
68
  # wrapping it in square brackets.
68
69
  hostname = address =~ Resolv::IPv6::Regex ? "[#{address}]" : address
69
- uri = req.uri || URI.parse(URI::DEFAULT_PARSER.escape("#{use_ssl? ? 'https' : 'http'}://#{hostname}#{req.path}"))
70
+ uri = req.uri || URI.parse(URI_PARSER.escape("#{use_ssl? ? 'https' : 'http'}://#{hostname}#{req.path}"))
70
71
  url = "#{uri.scheme}://#{uri.host}#{uri.path}" rescue uri.to_s
71
72
 
72
73
  result = { method: req.method, url: url }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
- VERSION = "5.22.1"
4
+ VERSION = "5.22.3"
5
5
  end
data/lib/sentry-ruby.rb CHANGED
@@ -308,6 +308,9 @@ module Sentry
308
308
  # @return [Hub]
309
309
  def get_main_hub
310
310
  MUTEX.synchronize { @main_hub }
311
+ rescue ThreadError
312
+ # In some rare cases this may be called in a trap context so we need to handle it gracefully
313
+ @main_hub
311
314
  end
312
315
 
313
316
  # Takes an instance of Sentry::Breadcrumb and stores it to the current active scope.
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.22.1
4
+ version: 5.22.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-16 00:00:00.000000000 Z
10
+ date: 2025-01-29 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: sentry-ruby
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - '='
18
17
  - !ruby/object:Gem::Version
19
- version: 5.22.1
18
+ version: 5.22.3
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - '='
25
24
  - !ruby/object:Gem::Version
26
- version: 5.22.1
25
+ version: 5.22.3
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: concurrent-ruby
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +151,6 @@ metadata:
152
151
  homepage_uri: https://github.com/getsentry/sentry-ruby
153
152
  source_code_uri: https://github.com/getsentry/sentry-ruby
154
153
  changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md
155
- post_install_message:
156
154
  rdoc_options: []
157
155
  require_paths:
158
156
  - lib
@@ -167,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
165
  - !ruby/object:Gem::Version
168
166
  version: '0'
169
167
  requirements: []
170
- rubygems_version: 3.5.22
171
- signing_key:
168
+ rubygems_version: 3.6.2
172
169
  specification_version: 4
173
170
  summary: A gem that provides a client interface for the Sentry error logger
174
171
  test_files: []