sentry-ruby-core 4.4.0.pre.beta.0 → 4.5.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 +4 -4
- data/.craft.yml +0 -1
- data/CHANGELOG.md +14 -1
- data/lib/sentry-ruby.rb +22 -1
- data/lib/sentry/client.rb +9 -1
- data/lib/sentry/configuration.rb +9 -1
- 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 +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b33a511a0da9a3c16aa740b759444644f6c2108521963ab04400efb6479ed8
|
4
|
+
data.tar.gz: 8aa9963c54219234d00124993810a228228d2ef936cfbf394abba1523a074a87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: addd108239cdd58fa36c77407b30cf126d009dacb4eeecee64ab82110ebb646adbc35f7c9bc197c8050affd9b3ac5cf8e8e6f3a6c853c3877b66f154649bde32
|
7
|
+
data.tar.gz: 5738472cc230dcd31486b246f27f163fe4c80cf500f556b3d21eff1b1b8d80c7e0730ed02955dc969340e872001810553c16ecfb0e7e00f67c7541b807d508e4
|
data/.craft.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
|
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
|
+
|
15
|
+
## 4.4.0
|
4
16
|
|
5
17
|
### Features
|
6
18
|
|
@@ -60,6 +72,7 @@ It'll determine whether the SDK should run in the debugging mode. Default is `fa
|
|
60
72
|
### Bug Fixes
|
61
73
|
|
62
74
|
- Check `Scope#set_context`'s value argument [#1415](https://github.com/getsentry/sentry-ruby/pull/1415)
|
75
|
+
- Disable tracing if events are not allowed to be sent [#1421](https://github.com/getsentry/sentry-ruby/pull/1421)
|
63
76
|
|
64
77
|
## 4.3.2
|
65
78
|
|
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/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
|
@@ -293,7 +301,7 @@ module Sentry
|
|
293
301
|
end
|
294
302
|
|
295
303
|
def tracing_enabled?
|
296
|
-
!!((@traces_sample_rate && @traces_sample_rate >= 0.0 && @traces_sample_rate <= 1.0) || @traces_sampler)
|
304
|
+
!!((@traces_sample_rate && @traces_sample_rate >= 0.0 && @traces_sample_rate <= 1.0) || @traces_sampler) && sending_allowed?
|
297
305
|
end
|
298
306
|
|
299
307
|
def stacktrace_builder
|
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.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-
|
11
|
+
date: 2021-05-27 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:
|
@@ -122,11 +122,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '2.4'
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- - "
|
125
|
+
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
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
|