sentry-ruby-core 4.4.2 → 4.5.0.pre.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/lib/sentry-ruby.rb +2 -0
- data/lib/sentry/client.rb +9 -1
- data/lib/sentry/configuration.rb +4 -0
- data/lib/sentry/net/http.rb +36 -0
- data/lib/sentry/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39b0d720876099298375f0ea0130ced0effa7fe7cb3c153d5075cff400788d7a
|
4
|
+
data.tar.gz: 3e89ef0214a1b632274605984514aa4703d6aea3bcc6c625d8f32eaa2f552203
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 263a733c7d5c2ca356a1de8f5b75b7ec1266e1ea6abe57b20db0a4789a2bd7bb1444dababc06a1291089c009dbcae05b8ded8a11bcd21f721ece3df454e1fb8b
|
7
|
+
data.tar.gz: b256b35de1a11df8e0b3468d47365fec0646da828f05e3161cd4b0374a5b7fda4586d911146895d04bb6574306688b587012c6b85d3b09baf096771efb3d1e49
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- Implement sentry-trace propagation [#1446](https://github.com/getsentry/sentry-ruby/pull/1446)
|
8
|
+
|
9
|
+
The SDK will insert the `sentry-trace` to outgoing requests made with `Net::HTTP`. Its value would look like `d827317d25d5420aa3aa97a0257db998-57757614642bdff5-1`.
|
10
|
+
|
11
|
+
If the receiver service also uses Sentry and the SDK supports performance monitoring, its tracing event will be connected with the sender application's.
|
12
|
+
|
13
|
+
Example:
|
14
|
+
|
15
|
+
<img width="1283" alt="connect sentry trace" src="https://user-images.githubusercontent.com/5079556/118963250-d7b40980-b998-11eb-9de4-598d1b220137.png">
|
16
|
+
|
17
|
+
This feature is activated by default. But users can use the new `config.propagate_traces` config option to disable it.
|
18
|
+
|
19
|
+
### Bug Fixes
|
20
|
+
|
21
|
+
- Allow toggling background sending on the fly [#1447](https://github.com/getsentry/sentry-ruby/pull/1447)
|
22
|
+
|
3
23
|
## 4.4.2
|
4
24
|
|
5
25
|
- Fix NoMethodError when SDK's dsn is nil [#1433](https://github.com/getsentry/sentry-ruby/pull/1433)
|
data/lib/sentry-ruby.rb
CHANGED
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
|
|
@@ -190,6 +193,7 @@ module Sentry
|
|
190
193
|
self.linecache = ::Sentry::LineCache.new
|
191
194
|
self.logger = ::Sentry::Logger.new(STDOUT)
|
192
195
|
self.project_root = Dir.pwd
|
196
|
+
self.propagate_traces = true
|
193
197
|
|
194
198
|
self.release = detect_release
|
195
199
|
self.sample_rate = 1.0
|
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?
|
data/lib/sentry/version.rb
CHANGED
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.pre.beta.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-05-
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -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: 1.3.1
|
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
|