sentry-ruby-core 4.8.0 → 4.8.1
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/lib/sentry/background_worker.rb +30 -2
- data/lib/sentry/breadcrumb/sentry_logger.rb +2 -0
- data/lib/sentry/breadcrumb.rb +2 -0
- data/lib/sentry/breadcrumb_buffer.rb +2 -0
- data/lib/sentry/client.rb +2 -0
- data/lib/sentry/configuration.rb +2 -0
- data/lib/sentry/core_ext/object/deep_dup.rb +2 -0
- data/lib/sentry/core_ext/object/duplicable.rb +1 -0
- data/lib/sentry/dsn.rb +2 -0
- data/lib/sentry/envelope.rb +25 -0
- data/lib/sentry/exceptions.rb +2 -0
- data/lib/sentry/hub.rb +2 -0
- data/lib/sentry/integrable.rb +2 -0
- data/lib/sentry/interface.rb +2 -0
- data/lib/sentry/interfaces/exception.rb +2 -0
- data/lib/sentry/interfaces/single_exception.rb +2 -0
- data/lib/sentry/interfaces/stacktrace.rb +2 -0
- data/lib/sentry/interfaces/stacktrace_builder.rb +2 -0
- data/lib/sentry/interfaces/threads.rb +2 -0
- data/lib/sentry/linecache.rb +2 -0
- data/lib/sentry/net/http.rb +2 -0
- data/lib/sentry/rack/capture_exceptions.rb +2 -0
- data/lib/sentry/rack.rb +2 -0
- data/lib/sentry/rake.rb +4 -4
- data/lib/sentry/release_detector.rb +2 -0
- data/lib/sentry/scope.rb +8 -4
- data/lib/sentry/span.rb +1 -0
- data/lib/sentry/transaction.rb +2 -0
- data/lib/sentry/transport/configuration.rb +2 -0
- data/lib/sentry/transport/dummy_transport.rb +2 -0
- data/lib/sentry/transport/http_transport.rb +6 -4
- data/lib/sentry/transport.rb +19 -24
- data/lib/sentry/utils/argument_checking_helper.rb +2 -0
- data/lib/sentry/utils/custom_inspection.rb +2 -0
- data/lib/sentry/utils/exception_cause_chain.rb +2 -0
- data/lib/sentry/utils/logging_helper.rb +2 -0
- data/lib/sentry/utils/real_ip.rb +2 -0
- data/lib/sentry/utils/request_id.rb +2 -0
- data/lib/sentry/version.rb +3 -1
- data/lib/sentry-ruby.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0d62d3133d461116b39ce7e822a3cc523c378417eafade8b3a904f76bce5289
|
4
|
+
data.tar.gz: 4ae280d6e7d88107e7f34f0794d266182d1c801407373023293c38db038aae50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8027f22238a8012bb1aca95d528cb479e287a5b6b17269c9789056d6959f33cab558fac3166147b82b2bda7ee6ad87f4d484ad83634d41804bf198ea7fddd7b2
|
7
|
+
data.tar.gz: ea6681465bf4f538139b0ba6057ea34dec7cb848e77be48ca65c5d7ee5080c492f324dda7903f40d1db275d4bea4f3887048ebf144d7748d02be35314e5fb977
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "concurrent/executor/thread_pool_executor"
|
2
4
|
require "concurrent/executor/immediate_executor"
|
3
5
|
require "concurrent/configuration"
|
@@ -7,11 +9,15 @@ module Sentry
|
|
7
9
|
include LoggingHelper
|
8
10
|
|
9
11
|
attr_reader :max_queue, :number_of_threads, :logger
|
12
|
+
attr_accessor :shutdown_timeout
|
10
13
|
|
11
14
|
def initialize(configuration)
|
12
15
|
@max_queue = 30
|
16
|
+
@shutdown_timeout = 1
|
13
17
|
@number_of_threads = configuration.background_worker_threads
|
14
18
|
@logger = configuration.logger
|
19
|
+
@debug = configuration.debug
|
20
|
+
@shutdown_callback = nil
|
15
21
|
|
16
22
|
@executor =
|
17
23
|
if configuration.async
|
@@ -23,19 +29,41 @@ module Sentry
|
|
23
29
|
else
|
24
30
|
log_debug("initialized a background worker with #{@number_of_threads} threads")
|
25
31
|
|
26
|
-
Concurrent::ThreadPoolExecutor.new(
|
32
|
+
executor = Concurrent::ThreadPoolExecutor.new(
|
27
33
|
min_threads: 0,
|
28
34
|
max_threads: @number_of_threads,
|
29
35
|
max_queue: @max_queue,
|
30
36
|
fallback_policy: :discard
|
31
37
|
)
|
38
|
+
|
39
|
+
@shutdown_callback = proc do
|
40
|
+
executor.shutdown
|
41
|
+
executor.wait_for_termination(@shutdown_timeout)
|
42
|
+
end
|
43
|
+
|
44
|
+
executor
|
32
45
|
end
|
33
46
|
end
|
34
47
|
|
48
|
+
# if you want to monkey-patch this method, please override `_perform` instead
|
35
49
|
def perform(&block)
|
36
50
|
@executor.post do
|
37
|
-
|
51
|
+
begin
|
52
|
+
_perform(&block)
|
53
|
+
rescue Exception => e
|
54
|
+
log_error("exception happened in background worker", e, debug: @debug)
|
55
|
+
end
|
38
56
|
end
|
39
57
|
end
|
58
|
+
|
59
|
+
def shutdown
|
60
|
+
@shutdown_callback&.call
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def _perform(&block)
|
66
|
+
block.call
|
67
|
+
end
|
40
68
|
end
|
41
69
|
end
|
data/lib/sentry/breadcrumb.rb
CHANGED
data/lib/sentry/client.rb
CHANGED
data/lib/sentry/configuration.rb
CHANGED
data/lib/sentry/dsn.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sentry
|
4
|
+
class Envelope
|
5
|
+
def initialize(headers)
|
6
|
+
@headers = headers
|
7
|
+
@items = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_item(headers, payload)
|
11
|
+
@items << [headers, payload]
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
payload = @items.map do |item_headers, item_payload|
|
16
|
+
<<~ENVELOPE
|
17
|
+
#{JSON.generate(item_headers)}
|
18
|
+
#{JSON.generate(item_payload)}
|
19
|
+
ENVELOPE
|
20
|
+
end.join("\n")
|
21
|
+
|
22
|
+
"#{JSON.generate(@headers)}\n#{payload}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/sentry/exceptions.rb
CHANGED
data/lib/sentry/hub.rb
CHANGED
data/lib/sentry/integrable.rb
CHANGED
data/lib/sentry/interface.rb
CHANGED
data/lib/sentry/linecache.rb
CHANGED
data/lib/sentry/net/http.rb
CHANGED
data/lib/sentry/rack.rb
CHANGED
data/lib/sentry/rake.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rake"
|
2
4
|
require "rake/task"
|
3
5
|
|
@@ -5,7 +7,7 @@ module Sentry
|
|
5
7
|
module Rake
|
6
8
|
module Application
|
7
9
|
def display_error_message(ex)
|
8
|
-
Sentry.capture_exception(ex
|
10
|
+
Sentry.capture_exception(ex) do |scope|
|
9
11
|
task_name = top_level_tasks.join(' ')
|
10
12
|
scope.set_transaction_name(task_name)
|
11
13
|
scope.set_tag("rake_task", task_name)
|
@@ -19,9 +21,7 @@ module Sentry
|
|
19
21
|
def execute(args=nil)
|
20
22
|
return super unless Sentry.initialized? && Sentry.get_current_hub
|
21
23
|
|
22
|
-
|
23
|
-
super
|
24
|
-
end
|
24
|
+
super
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/sentry/scope.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "sentry/breadcrumb_buffer"
|
2
4
|
require "etc"
|
3
5
|
|
@@ -112,7 +114,7 @@ module Sentry
|
|
112
114
|
end
|
113
115
|
|
114
116
|
def set_extra(key, value)
|
115
|
-
|
117
|
+
set_extras(key => value)
|
116
118
|
end
|
117
119
|
|
118
120
|
def set_tags(tags_hash)
|
@@ -121,17 +123,19 @@ module Sentry
|
|
121
123
|
end
|
122
124
|
|
123
125
|
def set_tag(key, value)
|
124
|
-
|
126
|
+
set_tags(key => value)
|
125
127
|
end
|
126
128
|
|
127
129
|
def set_contexts(contexts_hash)
|
128
130
|
check_argument_type!(contexts_hash, Hash)
|
129
|
-
@contexts.merge!(contexts_hash)
|
131
|
+
@contexts.merge!(contexts_hash) do |key, old, new|
|
132
|
+
new.merge(old)
|
133
|
+
end
|
130
134
|
end
|
131
135
|
|
132
136
|
def set_context(key, value)
|
133
137
|
check_argument_type!(value, Hash)
|
134
|
-
|
138
|
+
set_contexts(key => value)
|
135
139
|
end
|
136
140
|
|
137
141
|
def set_level(level)
|
data/lib/sentry/span.rb
CHANGED
data/lib/sentry/transaction.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
require 'zlib'
|
3
5
|
|
@@ -139,10 +141,10 @@ module Sentry
|
|
139
141
|
end
|
140
142
|
|
141
143
|
def ssl_configuration
|
142
|
-
|
143
|
-
:
|
144
|
-
:
|
145
|
-
)
|
144
|
+
{
|
145
|
+
verify: @transport_configuration.ssl_verification,
|
146
|
+
ca_file: @transport_configuration.ssl_ca_file
|
147
|
+
}.merge(@transport_configuration.ssl || {})
|
146
148
|
end
|
147
149
|
end
|
148
150
|
end
|
data/lib/sentry/transport.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "json"
|
2
4
|
require "base64"
|
5
|
+
require "sentry/envelope"
|
3
6
|
|
4
7
|
module Sentry
|
5
8
|
class Transport
|
@@ -103,31 +106,29 @@ module Sentry
|
|
103
106
|
def encode(event)
|
104
107
|
# Convert to hash
|
105
108
|
event_payload = event.to_hash
|
106
|
-
|
107
109
|
event_id = event_payload[:event_id] || event_payload["event_id"]
|
108
110
|
item_type = get_item_type(event_payload)
|
109
111
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
112
|
+
envelope = Envelope.new(
|
113
|
+
{
|
114
|
+
event_id: event_id,
|
115
|
+
dsn: @dsn.to_s,
|
116
|
+
sdk: Sentry.sdk_meta,
|
117
|
+
sent_at: Sentry.utc_now.iso8601
|
118
|
+
}
|
119
|
+
)
|
118
120
|
|
119
|
-
envelope
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
ENVELOPE
|
121
|
+
envelope.add_item(
|
122
|
+
{ type: item_type, content_type: 'application/json' },
|
123
|
+
event_payload
|
124
|
+
)
|
124
125
|
|
125
|
-
|
126
|
-
envelope
|
126
|
+
client_report_headers, client_report_payload = fetch_pending_client_report
|
127
|
+
envelope.add_item(client_report_headers, client_report_payload) if client_report_headers
|
127
128
|
|
128
129
|
log_info("Sending envelope [#{item_type}] #{event_id} to Sentry")
|
129
130
|
|
130
|
-
envelope
|
131
|
+
envelope.to_s
|
131
132
|
end
|
132
133
|
|
133
134
|
def record_lost_event(reason, item_type)
|
@@ -159,21 +160,15 @@ module Sentry
|
|
159
160
|
end
|
160
161
|
|
161
162
|
item_header = { type: 'client_report' }
|
162
|
-
|
163
163
|
item_payload = {
|
164
164
|
timestamp: Sentry.utc_now.iso8601,
|
165
165
|
discarded_events: discarded_events_hash
|
166
166
|
}
|
167
167
|
|
168
|
-
client_report_item = <<~CLIENT_REPORT_ITEM
|
169
|
-
#{JSON.generate(item_header)}
|
170
|
-
#{JSON.generate(item_payload)}
|
171
|
-
CLIENT_REPORT_ITEM
|
172
|
-
|
173
168
|
@discarded_events = Hash.new(0)
|
174
169
|
@last_client_report_sent = Time.now
|
175
170
|
|
176
|
-
|
171
|
+
[item_header, item_payload]
|
177
172
|
end
|
178
173
|
end
|
179
174
|
end
|
data/lib/sentry/utils/real_ip.rb
CHANGED
data/lib/sentry/version.rb
CHANGED
data/lib/sentry-ruby.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "English"
|
2
4
|
require "forwardable"
|
3
5
|
require "time"
|
@@ -108,6 +110,10 @@ module Sentry
|
|
108
110
|
if config.capture_exception_frame_locals
|
109
111
|
exception_locals_tp.enable
|
110
112
|
end
|
113
|
+
|
114
|
+
at_exit do
|
115
|
+
@background_worker.shutdown
|
116
|
+
end
|
111
117
|
end
|
112
118
|
|
113
119
|
# Returns an uri for security policy reporting that's generated from the given DSN
|
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.8.
|
4
|
+
version: 4.8.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-
|
11
|
+
date: 2021-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/sentry/core_ext/object/deep_dup.rb
|
69
69
|
- lib/sentry/core_ext/object/duplicable.rb
|
70
70
|
- lib/sentry/dsn.rb
|
71
|
+
- lib/sentry/envelope.rb
|
71
72
|
- lib/sentry/event.rb
|
72
73
|
- lib/sentry/exceptions.rb
|
73
74
|
- lib/sentry/hub.rb
|