sentry-ruby-core 4.4.0 → 4.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.craft.yml +0 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +3 -4
- data/lib/sentry-ruby.rb +22 -1
- data/lib/sentry/breadcrumb.rb +7 -2
- data/lib/sentry/client.rb +9 -1
- data/lib/sentry/configuration.rb +8 -0
- data/lib/sentry/net/http.rb +42 -3
- data/lib/sentry/rake.rb +1 -1
- data/lib/sentry/transport.rb +1 -1
- data/lib/sentry/version.rb +1 -1
- data/sentry-ruby-core.gemspec +1 -1
- data/sentry-ruby.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b3c9b486a84c3c47a161b6aa840c3b1e2e43946acd77e7caebe63e7c2c2fe58
|
4
|
+
data.tar.gz: db161d2d4379a8d0a9340e1c7edb113955221b04792d60d21e96d7624b3c76c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc596e7d1a951cef5298a18800728490976c2ec5bf3516e353364c6cf6f14af607e3faf2fd36949792a5ff38c534ea42b7384f88976428d355c2a9df55d41117
|
7
|
+
data.tar.gz: 138f3eb99eccbcc2286c0e82eeab7ccc2a44f45e112c5ef4e68513f73dc441c47558a77e8efd40838e39465c2181fe74dffc0a9280e04d2a6cbaf7d0260eabd5
|
data/.craft.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
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
|
+
|
5
|
+
## 4.4.2
|
6
|
+
|
7
|
+
- Fix NoMethodError when SDK's dsn is nil [#1433](https://github.com/getsentry/sentry-ruby/pull/1433)
|
8
|
+
- fix: Update protocol version to 7 [#1434](https://github.com/getsentry/sentry-ruby/pull/1434)
|
9
|
+
- Fixes [#867](https://github.com/getsentry/sentry-ruby/issues/867)
|
10
|
+
|
11
|
+
## 4.4.1
|
12
|
+
|
13
|
+
- Apply patches when initializing the SDK [#1432](https://github.com/getsentry/sentry-ruby/pull/1432)
|
14
|
+
|
3
15
|
## 4.4.0
|
4
16
|
|
5
17
|
### Features
|
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
|
-
|
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
@@ -7,7 +7,6 @@ require "sentry/exceptions"
|
|
7
7
|
require "sentry/core_ext/object/deep_dup"
|
8
8
|
require "sentry/utils/argument_checking_helper"
|
9
9
|
require "sentry/utils/logging_helper"
|
10
|
-
require "sentry/net/http"
|
11
10
|
require "sentry/configuration"
|
12
11
|
require "sentry/logger"
|
13
12
|
require "sentry/event"
|
@@ -33,6 +32,8 @@ module Sentry
|
|
33
32
|
|
34
33
|
LOGGER_PROGNAME = "sentry".freeze
|
35
34
|
|
35
|
+
SENTRY_TRACE_HEADER_NAME = "sentry-trace".freeze
|
36
|
+
|
36
37
|
THREAD_LOCAL = :sentry_hub
|
37
38
|
|
38
39
|
def self.sdk_meta
|
@@ -64,9 +65,26 @@ module Sentry
|
|
64
65
|
|
65
66
|
attr_accessor :background_worker
|
66
67
|
|
68
|
+
@@registered_patches = []
|
69
|
+
|
70
|
+
def register_patch(&block)
|
71
|
+
registered_patches << block
|
72
|
+
end
|
73
|
+
|
74
|
+
def apply_patches(config)
|
75
|
+
registered_patches.each do |patch|
|
76
|
+
patch.call(config)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def registered_patches
|
81
|
+
@@registered_patches
|
82
|
+
end
|
83
|
+
|
67
84
|
def init(&block)
|
68
85
|
config = Configuration.new
|
69
86
|
yield(config) if block_given?
|
87
|
+
apply_patches(config)
|
70
88
|
client = Client.new(config)
|
71
89
|
scope = Scope.new(max_breadcrumbs: config.max_breadcrumbs)
|
72
90
|
hub = Hub.new(client, scope)
|
@@ -190,3 +208,6 @@ module Sentry
|
|
190
208
|
end
|
191
209
|
end
|
192
210
|
end
|
211
|
+
|
212
|
+
# patches
|
213
|
+
require "sentry/net/http"
|
data/lib/sentry/breadcrumb.rb
CHANGED
@@ -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, :
|
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)
|
data/lib/sentry/configuration.rb
CHANGED
@@ -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,13 @@ 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
201
|
self.release = detect_release
|
195
202
|
self.sample_rate = 1.0
|
196
203
|
self.send_modules = true
|
197
204
|
self.send_default_pii = false
|
205
|
+
self.skip_rake_integration = false
|
198
206
|
self.trusted_proxies = []
|
199
207
|
self.dsn = ENV['SENTRY_DSN']
|
200
208
|
self.server_name = server_name_from_env
|
data/lib/sentry/net/http.rb
CHANGED
@@ -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?
|
@@ -71,8 +107,8 @@ module Sentry
|
|
71
107
|
end
|
72
108
|
|
73
109
|
def from_sentry_sdk?
|
74
|
-
|
75
|
-
|
110
|
+
dsn = Sentry.configuration.dsn
|
111
|
+
dsn && dsn.host == self.address
|
76
112
|
end
|
77
113
|
|
78
114
|
def extract_request_info(req)
|
@@ -84,4 +120,7 @@ module Sentry
|
|
84
120
|
end
|
85
121
|
end
|
86
122
|
|
87
|
-
|
123
|
+
Sentry.register_patch do
|
124
|
+
patch = Sentry::Net::HTTP
|
125
|
+
Net::HTTP.send(:prepend, patch) unless Net::HTTP.ancestors.include?(patch)
|
126
|
+
end
|
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
|
data/lib/sentry/transport.rb
CHANGED
data/lib/sentry/version.rb
CHANGED
data/sentry-ruby-core.gemspec
CHANGED
@@ -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/
|
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/
|
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
|
+
version: 4.5.1
|
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-
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -110,7 +110,7 @@ licenses:
|
|
110
110
|
metadata:
|
111
111
|
homepage_uri: https://github.com/getsentry/sentry-ruby
|
112
112
|
source_code_uri: https://github.com/getsentry/sentry-ruby
|
113
|
-
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/
|
113
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md
|
114
114
|
post_install_message:
|
115
115
|
rdoc_options: []
|
116
116
|
require_paths:
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
129
|
+
rubygems_version: 3.1.6
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: A gem that provides a client interface for the Sentry error logger
|