sentry-ruby-core 4.4.2 → 4.6.0.pre.beta.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: 46eeab9b7fdc33dd16bbcdd3c7623dcffdc2e70d1c9af0016c4584a08bf743dd
4
- data.tar.gz: 0ebfed842099817048aeb8754f27dfd7e637a66d8b9f64267bd1953cbd1f9645
3
+ metadata.gz: 3fd251a3cc580751fb454b148652d6cc3236a909ff08b401a4127ca29c8cb596
4
+ data.tar.gz: '094f5c198cfff5179a7139668a69679e934498dbcfb45ebb418f94e0255a3cc1'
5
5
  SHA512:
6
- metadata.gz: 76284658bda5c4856caf4017046d7f1d6481a11d9287ab0b9ac8363248d1606c7b7a274c9018b56db33062682ceac0f090d614b154048d9e17da4b0a11c98de1
7
- data.tar.gz: 3462df382685823d4cd77ac0278644144b0570c04f15db4b2a58d591de8cb25fe3762f222adaf4bb990934c476bfc49b18dfc072021e96bb3f50943caa3dceca
6
+ metadata.gz: 97e91ace33cd6158779c4478e9f5d678045dc3c67bcb776040c4e7bd009f8cd7f52bf0c58d2a22e430e339931c7bb9c32a667731abae859427ef0827825bebfa
7
+ data.tar.gz: 183c877035a4c8e2dfdda837dd048d65a16862aa29cb0c2490cdd974609d28722eefdd7eb2d0f62d07ffde8fab842fbc5c265f89e0d8f843b3c9e1eefef2f0af
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Changelog
2
2
 
3
+ Individual gem's changelog has been deprecated. Please check the [project changelog](https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md).
4
+
3
5
  ## 4.4.2
4
6
 
5
7
  - Fix NoMethodError when SDK's dsn is nil [#1433](https://github.com/getsentry/sentry-ruby/pull/1433)
data/Gemfile CHANGED
@@ -3,8 +3,7 @@ source "https://rubygems.org"
3
3
  gem "sentry-ruby-core", path: "./"
4
4
  gem "sentry-ruby", path: "./"
5
5
 
6
- # TODO: Remove this if https://github.com/jruby/jruby/issues/6547 is addressed
7
- gem "i18n", "<= 1.8.7"
6
+ gem "rack" unless ENV["WITHOUT_RACK"] == "1"
8
7
 
9
8
  gem "rake", "~> 12.0"
10
9
  gem "rspec", "~> 3.0"
@@ -12,10 +11,10 @@ gem "rspec-retry"
12
11
  gem "webmock"
13
12
  gem "timecop"
14
13
  gem "codecov", "0.2.12"
15
- gem "tapping_device"
16
14
 
15
+ gem "object_tracer"
16
+ gem "debug", github: "ruby/debug" if RUBY_VERSION.to_f >= 2.6
17
17
  gem "pry"
18
- gem "rack" unless ENV["WITHOUT_RACK"] == "1"
19
18
 
20
19
  gem "benchmark-ips"
21
20
  gem "benchmark_driver"
data/lib/sentry-ruby.rb CHANGED
@@ -32,6 +32,8 @@ module Sentry
32
32
 
33
33
  LOGGER_PROGNAME = "sentry".freeze
34
34
 
35
+ SENTRY_TRACE_HEADER_NAME = "sentry-trace".freeze
36
+
35
37
  THREAD_LOCAL = :sentry_hub
36
38
 
37
39
  def self.sdk_meta
@@ -82,6 +84,7 @@ module Sentry
82
84
  def init(&block)
83
85
  config = Configuration.new
84
86
  yield(config) if block_given?
87
+ config.detect_release
85
88
  apply_patches(config)
86
89
  client = Client.new(config)
87
90
  scope = Scope.new(max_breadcrumbs: config.max_breadcrumbs)
@@ -2,15 +2,16 @@ module Sentry
2
2
  class Breadcrumb
3
3
  DATA_SERIALIZATION_ERROR_MESSAGE = "[data were removed due to serialization issues]"
4
4
 
5
- attr_accessor :category, :data, :message, :level, :timestamp, :type
5
+ attr_accessor :category, :data, :level, :timestamp, :type
6
+ attr_reader :message
6
7
 
7
8
  def initialize(category: nil, data: nil, message: nil, timestamp: nil, level: nil, type: nil)
8
9
  @category = category
9
10
  @data = data || {}
10
11
  @level = level
11
- @message = message
12
12
  @timestamp = timestamp || Sentry.utc_now.to_i
13
13
  @type = type
14
+ self.message = message
14
15
  end
15
16
 
16
17
  def to_hash
@@ -24,6 +25,10 @@ module Sentry
24
25
  }
25
26
  end
26
27
 
28
+ def message=(msg)
29
+ @message = (msg || "").byteslice(0..Event::MAX_MESSAGE_SIZE_IN_BYTES)
30
+ end
31
+
27
32
  private
28
33
 
29
34
  def serialized_data
data/lib/sentry/client.rb CHANGED
@@ -30,7 +30,7 @@ module Sentry
30
30
 
31
31
  if async_block = configuration.async
32
32
  dispatch_async_event(async_block, event, hint)
33
- elsif hint.fetch(:background, true)
33
+ elsif configuration.background_worker_threads != 0 && hint.fetch(:background, true)
34
34
  dispatch_background_event(event, hint)
35
35
  else
36
36
  send_event(event, hint)
@@ -95,6 +95,14 @@ module Sentry
95
95
  raise
96
96
  end
97
97
 
98
+ def generate_sentry_trace(span)
99
+ return unless configuration.propagate_traces
100
+
101
+ trace = span.to_sentry_trace
102
+ log_debug("[Tracing] Adding #{SENTRY_TRACE_HEADER_NAME} header to outgoing request: #{trace}")
103
+ trace
104
+ end
105
+
98
106
  private
99
107
 
100
108
  def dispatch_background_event(event, hint)
@@ -106,6 +106,9 @@ module Sentry
106
106
  # Set automatically for Rails.
107
107
  attr_reader :project_root
108
108
 
109
+ # Insert sentry-trace to outgoing requests' headers
110
+ attr_accessor :propagate_traces
111
+
109
112
  # Array of rack env parameters to be included in the event sent to sentry.
110
113
  attr_accessor :rack_env_whitelist
111
114
 
@@ -127,6 +130,9 @@ module Sentry
127
130
  # will not be sent to Sentry.
128
131
  attr_accessor :send_default_pii
129
132
 
133
+ # Allow to skip Sentry emails within rake tasks
134
+ attr_accessor :skip_rake_integration
135
+
130
136
  # IP ranges for trusted proxies that will be skipped when calculating IP address.
131
137
  attr_accessor :trusted_proxies
132
138
 
@@ -190,11 +196,12 @@ module Sentry
190
196
  self.linecache = ::Sentry::LineCache.new
191
197
  self.logger = ::Sentry::Logger.new(STDOUT)
192
198
  self.project_root = Dir.pwd
199
+ self.propagate_traces = true
193
200
 
194
- self.release = detect_release
195
201
  self.sample_rate = 1.0
196
202
  self.send_modules = true
197
203
  self.send_default_pii = false
204
+ self.skip_rake_integration = false
198
205
  self.trusted_proxies = []
199
206
  self.dsn = ENV['SENTRY_DSN']
200
207
  self.server_name = server_name_from_env
@@ -306,10 +313,10 @@ module Sentry
306
313
  )
307
314
  end
308
315
 
309
- private
310
-
311
316
  def detect_release
312
- detect_release_from_env ||
317
+ return unless sending_allowed?
318
+
319
+ self.release ||= detect_release_from_env ||
313
320
  detect_release_from_git ||
314
321
  detect_release_from_capistrano ||
315
322
  detect_release_from_heroku
@@ -317,6 +324,8 @@ module Sentry
317
324
  log_error("Error detecting release", e, debug: debug)
318
325
  end
319
326
 
327
+ private
328
+
320
329
  def excluded_exception?(incoming_exception)
321
330
  excluded_exception_classes.any? do |excluded_exception|
322
331
  matches_exception?(excluded_exception, incoming_exception)
@@ -57,6 +57,7 @@ module Sentry
57
57
  request.POST
58
58
  elsif request.body # JSON requests, etc
59
59
  data = request.body.read(MAX_BODY_LIMIT)
60
+ data = data.force_encoding(Encoding::UTF_8) if data.respond_to?(:force_encoding)
60
61
  request.body.rewind
61
62
  data
62
63
  end
@@ -5,7 +5,36 @@ module Sentry
5
5
  module HTTP
6
6
  OP_NAME = "net.http"
7
7
 
8
+ # To explain how the entire thing works, we need to know how the original Net::HTTP#request works
9
+ # Here's part of its definition. As you can see, it usually calls itself inside a #start block
10
+ #
11
+ # ```
12
+ # def request(req, body = nil, &block)
13
+ # unless started?
14
+ # start {
15
+ # req['connection'] ||= 'close'
16
+ # return request(req, body, &block) # <- request will be called for the second time from the first call
17
+ # }
18
+ # end
19
+ # # .....
20
+ # end
21
+ # ```
22
+ #
23
+ # So when the entire flow looks like this:
24
+ #
25
+ # 1. #request is called.
26
+ # - But because the request hasn't started yet, it calls #start (which then calls #do_start)
27
+ # - At this moment @sentry_span is still nil, so #set_sentry_trace_header returns early
28
+ # 2. #do_start then creates a new Span and assigns it to @sentry_span
29
+ # 3. #request is called for the second time.
30
+ # - This time @sentry_span should present. So #set_sentry_trace_header will set the sentry-trace header on the request object
31
+ # 4. Once the request finished, it
32
+ # - Records a breadcrumb if http_logger is set
33
+ # - Finishes the Span inside @sentry_span and clears the instance variable
34
+ #
8
35
  def request(req, body = nil, &block)
36
+ set_sentry_trace_header(req)
37
+
9
38
  super.tap do |res|
10
39
  record_sentry_breadcrumb(req, res)
11
40
  record_sentry_span(req, res)
@@ -26,6 +55,13 @@ module Sentry
26
55
 
27
56
  private
28
57
 
58
+ def set_sentry_trace_header(req)
59
+ return unless @sentry_span
60
+
61
+ trace = Sentry.get_current_client.generate_sentry_trace(@sentry_span)
62
+ req[SENTRY_TRACE_HEADER_NAME] = trace if trace
63
+ end
64
+
29
65
  def record_sentry_breadcrumb(req, res)
30
66
  if Sentry.initialized? && Sentry.configuration.breadcrumbs_logger.include?(:http_logger)
31
67
  return if from_sentry_sdk?
data/lib/sentry/rack.rb CHANGED
@@ -1,4 +1,3 @@
1
1
  require 'rack'
2
2
 
3
3
  require 'sentry/rack/capture_exceptions'
4
- require 'sentry/rack/deprecations'
data/lib/sentry/rake.rb CHANGED
@@ -9,7 +9,7 @@ module Rake
9
9
  task_name = top_level_tasks.join(' ')
10
10
  scope.set_transaction_name(task_name)
11
11
  scope.set_tag("rake_task", task_name)
12
- end if Sentry.initialized?
12
+ end if Sentry.initialized? && !Sentry.configuration.skip_rake_integration
13
13
 
14
14
  orig_display_error_messsage(ex)
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module Sentry
2
- VERSION = "4.4.2"
2
+ VERSION = "4.6.0-beta.0"
3
3
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/sentry-ruby/CHANGELOG.md"
19
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
20
20
 
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
data/sentry-ruby.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = spec.homepage
18
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/sentry-ruby/CHANGELOG.md"
18
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
19
19
 
20
20
  spec.add_dependency "sentry-ruby-core", Sentry::VERSION
21
21
  spec.add_dependency "faraday", ">= 1.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.2
4
+ version: 4.6.0.pre.beta.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-11 00:00:00.000000000 Z
11
+ date: 2021-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -46,7 +46,6 @@ extra_rdoc_files:
46
46
  - README.md
47
47
  - LICENSE.txt
48
48
  files:
49
- - ".craft.yml"
50
49
  - ".gitignore"
51
50
  - ".rspec"
52
51
  - CHANGELOG.md
@@ -61,7 +60,6 @@ files:
61
60
  - lib/sentry-ruby.rb
62
61
  - lib/sentry/background_worker.rb
63
62
  - lib/sentry/backtrace.rb
64
- - lib/sentry/benchmarks/benchmark_transport.rb
65
63
  - lib/sentry/breadcrumb.rb
66
64
  - lib/sentry/breadcrumb/sentry_logger.rb
67
65
  - lib/sentry/breadcrumb_buffer.rb
@@ -86,7 +84,6 @@ files:
86
84
  - lib/sentry/net/http.rb
87
85
  - lib/sentry/rack.rb
88
86
  - lib/sentry/rack/capture_exceptions.rb
89
- - lib/sentry/rack/deprecations.rb
90
87
  - lib/sentry/rake.rb
91
88
  - lib/sentry/scope.rb
92
89
  - lib/sentry/span.rb
@@ -110,7 +107,7 @@ licenses:
110
107
  metadata:
111
108
  homepage_uri: https://github.com/getsentry/sentry-ruby
112
109
  source_code_uri: https://github.com/getsentry/sentry-ruby
113
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/sentry-ruby/CHANGELOG.md
110
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md
114
111
  post_install_message:
115
112
  rdoc_options: []
116
113
  require_paths:
@@ -122,11 +119,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
119
  version: '2.4'
123
120
  required_rubygems_version: !ruby/object:Gem::Requirement
124
121
  requirements:
125
- - - ">="
122
+ - - ">"
126
123
  - !ruby/object:Gem::Version
127
- version: '0'
124
+ version: 1.3.1
128
125
  requirements: []
129
- rubygems_version: 3.0.3.1
126
+ rubygems_version: 3.1.6
130
127
  signing_key:
131
128
  specification_version: 4
132
129
  summary: A gem that provides a client interface for the Sentry error logger
data/.craft.yml DELETED
@@ -1,28 +0,0 @@
1
- minVersion: '0.13.2'
2
- github:
3
- owner: getsentry
4
- repo: sentry-ruby
5
- changelogPolicy: simple
6
- preReleaseCommand: ruby ../.scripts/bump-version.rb
7
- releaseBranchPrefix: release-sentry-ruby
8
- statusProvider:
9
- name: github
10
- artifactProvider:
11
- name: github
12
- targets:
13
- # we always need to make sure sentry-ruby-core is present when pushing to any target
14
- - name: gem
15
- onlyIfPresent: /^sentry-ruby-core-\d.*\.gem$/
16
- - name: registry
17
- onlyIfPresent: /^sentry-ruby-core-\d.*\.gem$/
18
- type: sdk
19
- config:
20
- canonical: 'gem:sentry-ruby'
21
- - name: registry
22
- onlyIfPresent: /^sentry-ruby-core-\d.*\.gem$/
23
- type: sdk
24
- config:
25
- canonical: 'gem:sentry-ruby-core'
26
- - name: github
27
- onlyIfPresent: /^sentry-ruby-core-\d.*\.gem$/
28
- tagPrefix: sentry-ruby-v
@@ -1,14 +0,0 @@
1
- module Sentry
2
- class BenchmarkTransport < Transport
3
- attr_accessor :events
4
-
5
- def initialize(*)
6
- super
7
- @events = []
8
- end
9
-
10
- def send_event(event)
11
- @events << encode(event.to_hash)
12
- end
13
- end
14
- end
@@ -1,19 +0,0 @@
1
- module Sentry
2
- module Rack
3
- class DeprecatedMiddleware
4
- def initialize(_)
5
- raise Sentry::Error.new <<~MSG
6
-
7
- You're seeing this message because #{self.class} has been replaced by Sentry::Rack::CaptureExceptions.
8
- Removing this middleware from your app and upgrading sentry-rails to 4.1.0+ should solve the issue.
9
- MSG
10
- end
11
- end
12
-
13
- class Tracing < DeprecatedMiddleware
14
- end
15
-
16
- class CaptureException < DeprecatedMiddleware
17
- end
18
- end
19
- end