sentry-ruby-core 4.8.0 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/Gemfile +2 -0
- data/README.md +2 -0
- data/lib/sentry/background_worker.rb +33 -3
- data/lib/sentry/backtrace.rb +1 -3
- data/lib/sentry/breadcrumb/sentry_logger.rb +2 -0
- data/lib/sentry/breadcrumb.rb +24 -3
- data/lib/sentry/breadcrumb_buffer.rb +16 -0
- data/lib/sentry/client.rb +33 -1
- data/lib/sentry/configuration.rb +88 -41
- 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 +26 -0
- data/lib/sentry/event.rb +54 -18
- 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 +3 -10
- data/lib/sentry/interfaces/exception.rb +13 -3
- data/lib/sentry/interfaces/request.rb +34 -18
- data/lib/sentry/interfaces/single_exception.rb +2 -0
- data/lib/sentry/interfaces/stacktrace.rb +6 -0
- data/lib/sentry/interfaces/stacktrace_builder.rb +39 -10
- data/lib/sentry/interfaces/threads.rb +12 -2
- data/lib/sentry/linecache.rb +3 -0
- data/lib/sentry/net/http.rb +52 -64
- data/lib/sentry/rack/capture_exceptions.rb +2 -0
- data/lib/sentry/rack.rb +2 -0
- data/lib/sentry/rake.rb +16 -6
- data/lib/sentry/release_detector.rb +3 -0
- data/lib/sentry/scope.rb +75 -5
- data/lib/sentry/span.rb +84 -8
- data/lib/sentry/transaction.rb +44 -9
- data/lib/sentry/transaction_event.rb +8 -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 +23 -25
- 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 +6 -4
- 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 +122 -29
- data/sentry-ruby.gemspec +1 -1
- metadata +4 -2
data/lib/sentry/rake.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rake"
|
2
4
|
require "rake/task"
|
3
5
|
|
4
6
|
module Sentry
|
5
7
|
module Rake
|
6
8
|
module Application
|
9
|
+
# @api private
|
7
10
|
def display_error_message(ex)
|
8
|
-
Sentry.capture_exception(ex
|
11
|
+
Sentry.capture_exception(ex) do |scope|
|
9
12
|
task_name = top_level_tasks.join(' ')
|
10
13
|
scope.set_transaction_name(task_name)
|
11
14
|
scope.set_tag("rake_task", task_name)
|
@@ -16,16 +19,23 @@ module Sentry
|
|
16
19
|
end
|
17
20
|
|
18
21
|
module Task
|
22
|
+
# @api private
|
19
23
|
def execute(args=nil)
|
20
24
|
return super unless Sentry.initialized? && Sentry.get_current_hub
|
21
25
|
|
22
|
-
|
23
|
-
super
|
24
|
-
end
|
26
|
+
super
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
|
31
|
-
Rake
|
32
|
+
# @api private
|
33
|
+
module Rake
|
34
|
+
class Application
|
35
|
+
prepend(Sentry::Rake::Application)
|
36
|
+
end
|
37
|
+
|
38
|
+
class Task
|
39
|
+
prepend(Sentry::Rake::Task)
|
40
|
+
end
|
41
|
+
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
|
|
@@ -9,15 +11,22 @@ module Sentry
|
|
9
11
|
|
10
12
|
attr_reader(*ATTRIBUTES)
|
11
13
|
|
14
|
+
# @param max_breadcrumbs [Integer] the maximum number of breadcrumbs to be stored in the scope.
|
12
15
|
def initialize(max_breadcrumbs: nil)
|
13
16
|
@max_breadcrumbs = max_breadcrumbs
|
14
17
|
set_default_value
|
15
18
|
end
|
16
19
|
|
20
|
+
# Resets the scope's attributes to defaults.
|
21
|
+
# @return [void]
|
17
22
|
def clear
|
18
23
|
set_default_value
|
19
24
|
end
|
20
25
|
|
26
|
+
# Applies stored attributes and event processors to the given event.
|
27
|
+
# @param event [Event]
|
28
|
+
# @param hint [Hash] the hint data that'll be passed to event processors.
|
29
|
+
# @return [Event]
|
21
30
|
def apply_to_event(event, hint = nil)
|
22
31
|
event.tags = tags.merge(event.tags)
|
23
32
|
event.user = user.merge(event.user)
|
@@ -43,14 +52,20 @@ module Sentry
|
|
43
52
|
event
|
44
53
|
end
|
45
54
|
|
55
|
+
# Adds the breadcrumb to the scope's breadcrumbs buffer.
|
56
|
+
# @param breadcrumb [Breadcrumb]
|
57
|
+
# @return [void]
|
46
58
|
def add_breadcrumb(breadcrumb)
|
47
59
|
breadcrumbs.record(breadcrumb)
|
48
60
|
end
|
49
61
|
|
62
|
+
# Clears the scope's breadcrumbs buffer
|
63
|
+
# @return [void]
|
50
64
|
def clear_breadcrumbs
|
51
65
|
set_new_breadcrumb_buffer
|
52
66
|
end
|
53
67
|
|
68
|
+
# @return [Scope]
|
54
69
|
def dup
|
55
70
|
copy = super
|
56
71
|
copy.breadcrumbs = breadcrumbs.dup
|
@@ -64,6 +79,9 @@ module Sentry
|
|
64
79
|
copy
|
65
80
|
end
|
66
81
|
|
82
|
+
# Updates the scope's data from a given scope.
|
83
|
+
# @param scope [Scope]
|
84
|
+
# @return [void]
|
67
85
|
def update_from_scope(scope)
|
68
86
|
self.breadcrumbs = scope.breadcrumbs
|
69
87
|
self.contexts = scope.contexts
|
@@ -75,6 +93,14 @@ module Sentry
|
|
75
93
|
self.span = scope.span
|
76
94
|
end
|
77
95
|
|
96
|
+
# Updates the scope's data from the given options.
|
97
|
+
# @param contexts [Hash]
|
98
|
+
# @param extras [Hash]
|
99
|
+
# @param tags [Hash]
|
100
|
+
# @param user [Hash]
|
101
|
+
# @param level [String, Symbol]
|
102
|
+
# @param fingerprint [Array]
|
103
|
+
# @return [void]
|
78
104
|
def update_from_options(
|
79
105
|
contexts: nil,
|
80
106
|
extra: nil,
|
@@ -91,75 +117,118 @@ module Sentry
|
|
91
117
|
self.fingerprint = fingerprint if fingerprint
|
92
118
|
end
|
93
119
|
|
120
|
+
# Sets the scope's rack_env attribute.
|
121
|
+
# @param env [Hash]
|
122
|
+
# @return [Hash]
|
94
123
|
def set_rack_env(env)
|
95
124
|
env = env || {}
|
96
125
|
@rack_env = env
|
97
126
|
end
|
98
127
|
|
128
|
+
# Sets the scope's span attribute.
|
129
|
+
# @param span [Span]
|
130
|
+
# @return [Span]
|
99
131
|
def set_span(span)
|
100
132
|
check_argument_type!(span, Span)
|
101
133
|
@span = span
|
102
134
|
end
|
103
135
|
|
136
|
+
# @!macro set_user
|
104
137
|
def set_user(user_hash)
|
105
138
|
check_argument_type!(user_hash, Hash)
|
106
139
|
@user = user_hash
|
107
140
|
end
|
108
141
|
|
142
|
+
# @!macro set_extras
|
109
143
|
def set_extras(extras_hash)
|
110
144
|
check_argument_type!(extras_hash, Hash)
|
111
145
|
@extra.merge!(extras_hash)
|
112
146
|
end
|
113
147
|
|
148
|
+
# Adds a new key-value pair to current extras.
|
149
|
+
# @param key [String, Symbol]
|
150
|
+
# @param value [Object]
|
151
|
+
# @return [Hash]
|
114
152
|
def set_extra(key, value)
|
115
|
-
|
153
|
+
set_extras(key => value)
|
116
154
|
end
|
117
155
|
|
156
|
+
# @!macro set_tags
|
118
157
|
def set_tags(tags_hash)
|
119
158
|
check_argument_type!(tags_hash, Hash)
|
120
159
|
@tags.merge!(tags_hash)
|
121
160
|
end
|
122
161
|
|
162
|
+
# Adds a new key-value pair to current tags.
|
163
|
+
# @param key [String, Symbol]
|
164
|
+
# @param value [Object]
|
165
|
+
# @return [Hash]
|
123
166
|
def set_tag(key, value)
|
124
|
-
|
167
|
+
set_tags(key => value)
|
125
168
|
end
|
126
169
|
|
170
|
+
# Updates the scope's contexts attribute by merging with the old value.
|
171
|
+
# @param contexts [Hash]
|
172
|
+
# @return [Hash]
|
127
173
|
def set_contexts(contexts_hash)
|
128
174
|
check_argument_type!(contexts_hash, Hash)
|
129
|
-
@contexts.merge!(contexts_hash)
|
175
|
+
@contexts.merge!(contexts_hash) do |key, old, new|
|
176
|
+
new.merge(old)
|
177
|
+
end
|
130
178
|
end
|
131
179
|
|
180
|
+
# @!macro set_context
|
132
181
|
def set_context(key, value)
|
133
182
|
check_argument_type!(value, Hash)
|
134
|
-
|
183
|
+
set_contexts(key => value)
|
135
184
|
end
|
136
185
|
|
186
|
+
# Sets the scope's level attribute.
|
187
|
+
# @param level [String, Symbol]
|
188
|
+
# @return [void]
|
137
189
|
def set_level(level)
|
138
190
|
@level = level
|
139
191
|
end
|
140
192
|
|
193
|
+
# Appends a new transaction name to the scope.
|
194
|
+
# The "transaction" here does not refer to `Transaction` objects.
|
195
|
+
# @param transaction_name [String]
|
196
|
+
# @return [void]
|
141
197
|
def set_transaction_name(transaction_name)
|
142
198
|
@transaction_names << transaction_name
|
143
199
|
end
|
144
200
|
|
201
|
+
# Returns current transaction name.
|
202
|
+
# The "transaction" here does not refer to `Transaction` objects.
|
203
|
+
# @return [String, nil]
|
145
204
|
def transaction_name
|
146
205
|
@transaction_names.last
|
147
206
|
end
|
148
207
|
|
208
|
+
# Returns the associated Transaction object.
|
209
|
+
# @return [Transaction, nil]
|
149
210
|
def get_transaction
|
150
211
|
span.transaction if span
|
151
212
|
end
|
152
213
|
|
214
|
+
# Returns the associated Span object.
|
215
|
+
# @return [Span, nil]
|
153
216
|
def get_span
|
154
217
|
span
|
155
218
|
end
|
156
219
|
|
220
|
+
# Sets the scope's fingerprint attribute.
|
221
|
+
# @param fingerprint [Array]
|
222
|
+
# @return [Array]
|
157
223
|
def set_fingerprint(fingerprint)
|
158
224
|
check_argument_type!(fingerprint, Array)
|
159
225
|
|
160
226
|
@fingerprint = fingerprint
|
161
227
|
end
|
162
228
|
|
229
|
+
# Adds a new event processor [Proc] to the scope.
|
230
|
+
# @param block [Proc]
|
231
|
+
# @return [void]
|
163
232
|
def add_event_processor(&block)
|
164
233
|
@event_processors << block
|
165
234
|
end
|
@@ -189,8 +258,8 @@ module Sentry
|
|
189
258
|
@breadcrumbs = BreadcrumbBuffer.new(@max_breadcrumbs)
|
190
259
|
end
|
191
260
|
|
192
|
-
|
193
261
|
class << self
|
262
|
+
# @return [Hash]
|
194
263
|
def os_context
|
195
264
|
@os_context ||=
|
196
265
|
begin
|
@@ -204,6 +273,7 @@ module Sentry
|
|
204
273
|
end
|
205
274
|
end
|
206
275
|
|
276
|
+
# @return [Hash]
|
207
277
|
def runtime_context
|
208
278
|
@runtime_context ||= {
|
209
279
|
name: RbConfig::CONFIG["ruby_install_name"],
|
data/lib/sentry/span.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "securerandom"
|
3
4
|
|
4
5
|
module Sentry
|
@@ -17,9 +18,49 @@ module Sentry
|
|
17
18
|
504 => "deadline_exceeded"
|
18
19
|
}
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
# An uuid that can be used to identify a trace.
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :trace_id
|
24
|
+
# An uuid that can be used to identify the span.
|
25
|
+
# @return [String]
|
26
|
+
attr_reader :span_id
|
27
|
+
# Span parent's span_id.
|
28
|
+
# @return [String]
|
29
|
+
attr_reader :parent_span_id
|
30
|
+
# Sampling result of the span.
|
31
|
+
# @return [Boolean, nil]
|
32
|
+
attr_reader :sampled
|
33
|
+
# Starting timestamp of the span.
|
34
|
+
# @return [Float]
|
35
|
+
attr_reader :start_timestamp
|
36
|
+
# Finishing timestamp of the span.
|
37
|
+
# @return [Float]
|
38
|
+
attr_reader :timestamp
|
39
|
+
# Span description
|
40
|
+
# @return [String]
|
41
|
+
attr_reader :description
|
42
|
+
# Span operation
|
43
|
+
# @return [String]
|
44
|
+
attr_reader :op
|
45
|
+
# Span status
|
46
|
+
# @return [String]
|
47
|
+
attr_reader :status
|
48
|
+
# Span tags
|
49
|
+
# @return [Hash]
|
50
|
+
attr_reader :tags
|
51
|
+
# Span data
|
52
|
+
# @return [Hash]
|
53
|
+
attr_reader :data
|
54
|
+
|
55
|
+
# The SpanRecorder the current span belongs to.
|
56
|
+
# SpanRecorder holds all spans under the same Transaction object (including the Transaction itself).
|
57
|
+
# @return [SpanRecorder]
|
58
|
+
attr_accessor :span_recorder
|
59
|
+
|
60
|
+
# The Transaction object the Span belongs to.
|
61
|
+
# Every span needs to be attached to a Transaction and their child spans will also inherit the same transaction.
|
62
|
+
# @return [Transaction]
|
63
|
+
attr_accessor :transaction
|
23
64
|
|
24
65
|
def initialize(
|
25
66
|
description: nil,
|
@@ -44,6 +85,8 @@ module Sentry
|
|
44
85
|
@tags = {}
|
45
86
|
end
|
46
87
|
|
88
|
+
# Finishes the span by adding a timestamp.
|
89
|
+
# @return [self]
|
47
90
|
def finish
|
48
91
|
# already finished
|
49
92
|
return if @timestamp
|
@@ -52,6 +95,8 @@ module Sentry
|
|
52
95
|
self
|
53
96
|
end
|
54
97
|
|
98
|
+
# Generates a trace string that can be used to connect other transactions.
|
99
|
+
# @return [String]
|
55
100
|
def to_sentry_trace
|
56
101
|
sampled_flag = ""
|
57
102
|
sampled_flag = @sampled ? 1 : 0 unless @sampled.nil?
|
@@ -59,6 +104,7 @@ module Sentry
|
|
59
104
|
"#{@trace_id}-#{@span_id}-#{sampled_flag}"
|
60
105
|
end
|
61
106
|
|
107
|
+
# @return [Hash]
|
62
108
|
def to_hash
|
63
109
|
{
|
64
110
|
trace_id: @trace_id,
|
@@ -74,6 +120,8 @@ module Sentry
|
|
74
120
|
}
|
75
121
|
end
|
76
122
|
|
123
|
+
# Returns the span's context that can be used to embed in an Event.
|
124
|
+
# @return [Hash]
|
77
125
|
def get_trace_context
|
78
126
|
{
|
79
127
|
trace_id: @trace_id,
|
@@ -85,9 +133,11 @@ module Sentry
|
|
85
133
|
}
|
86
134
|
end
|
87
135
|
|
88
|
-
|
89
|
-
|
90
|
-
|
136
|
+
# Starts a child span with given attributes.
|
137
|
+
# @param attributes [Hash] the attributes for the child span.
|
138
|
+
def start_child(**attributes)
|
139
|
+
attributes = attributes.dup.merge(trace_id: @trace_id, parent_span_id: @span_id, sampled: @sampled)
|
140
|
+
new_span = Span.new(**attributes)
|
91
141
|
new_span.transaction = transaction
|
92
142
|
new_span.span_recorder = span_recorder
|
93
143
|
|
@@ -98,8 +148,17 @@ module Sentry
|
|
98
148
|
new_span
|
99
149
|
end
|
100
150
|
|
101
|
-
|
102
|
-
|
151
|
+
# Starts a child span, yield it to the given block, and then finish the span after the block is executed.
|
152
|
+
# @example
|
153
|
+
# span.with_child_span do |child_span|
|
154
|
+
# # things happen here will be recorded in a child span
|
155
|
+
# end
|
156
|
+
#
|
157
|
+
# @param attributes [Hash] the attributes for the child span.
|
158
|
+
# @param block [Proc] the action to be recorded in the child span.
|
159
|
+
# @yieldparam child_span [Span]
|
160
|
+
def with_child_span(**attributes, &block)
|
161
|
+
child_span = start_child(**attributes)
|
103
162
|
|
104
163
|
yield(child_span)
|
105
164
|
|
@@ -110,22 +169,33 @@ module Sentry
|
|
110
169
|
dup
|
111
170
|
end
|
112
171
|
|
172
|
+
# Sets the span's operation.
|
173
|
+
# @param op [String] operation of the span.
|
113
174
|
def set_op(op)
|
114
175
|
@op = op
|
115
176
|
end
|
116
177
|
|
178
|
+
# Sets the span's description.
|
179
|
+
# @param description [String] description of the span.
|
117
180
|
def set_description(description)
|
118
181
|
@description = description
|
119
182
|
end
|
120
183
|
|
184
|
+
|
185
|
+
# Sets the span's status.
|
186
|
+
# @param satus [String] status of the span.
|
121
187
|
def set_status(status)
|
122
188
|
@status = status
|
123
189
|
end
|
124
190
|
|
191
|
+
# Sets the span's finish timestamp.
|
192
|
+
# @param timestamp [Float] finished time in float format (most precise).
|
125
193
|
def set_timestamp(timestamp)
|
126
194
|
@timestamp = timestamp
|
127
195
|
end
|
128
196
|
|
197
|
+
# Sets the span's status with given http status code.
|
198
|
+
# @param status_code [String] example: "500".
|
129
199
|
def set_http_status(status_code)
|
130
200
|
status_code = status_code.to_i
|
131
201
|
set_data("status_code", status_code)
|
@@ -139,10 +209,16 @@ module Sentry
|
|
139
209
|
set_status(status)
|
140
210
|
end
|
141
211
|
|
212
|
+
# Inserts a key-value pair to the span's data payload.
|
213
|
+
# @param key [String, Symbol]
|
214
|
+
# @param value [Object]
|
142
215
|
def set_data(key, value)
|
143
216
|
@data[key] = value
|
144
217
|
end
|
145
218
|
|
219
|
+
# Sets a tag to the span.
|
220
|
+
# @param key [String, Symbol]
|
221
|
+
# @param value [String]
|
146
222
|
def set_tag(key, value)
|
147
223
|
@tags[key] = value
|
148
224
|
end
|
data/lib/sentry/transaction.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Sentry
|
2
4
|
class Transaction < Span
|
3
5
|
SENTRY_TRACE_REGEXP = Regexp.new(
|
@@ -12,7 +14,22 @@ module Sentry
|
|
12
14
|
|
13
15
|
include LoggingHelper
|
14
16
|
|
15
|
-
|
17
|
+
# The name of the transaction.
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :name
|
20
|
+
|
21
|
+
# The sampling decision of the parent transaction, which will be considered when making the current transaction's sampling decision.
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :parent_sampled
|
24
|
+
|
25
|
+
# @deprecated Use Sentry.get_current_hub instead.
|
26
|
+
attr_reader :hub
|
27
|
+
|
28
|
+
# @deprecated Use Sentry.configuration instead.
|
29
|
+
attr_reader :configuration
|
30
|
+
|
31
|
+
# @deprecated Use Sentry.logger instead.
|
32
|
+
attr_reader :logger
|
16
33
|
|
17
34
|
def initialize(name: nil, parent_sampled: nil, hub:, **options)
|
18
35
|
super(**options)
|
@@ -21,11 +38,23 @@ module Sentry
|
|
21
38
|
@parent_sampled = parent_sampled
|
22
39
|
@transaction = self
|
23
40
|
@hub = hub
|
24
|
-
@configuration = hub.configuration
|
25
|
-
@
|
41
|
+
@configuration = hub.configuration # to be removed
|
42
|
+
@tracing_enabled = hub.configuration.tracing_enabled?
|
43
|
+
@traces_sampler = hub.configuration.traces_sampler
|
44
|
+
@traces_sample_rate = hub.configuration.traces_sample_rate
|
45
|
+
@logger = hub.configuration.logger
|
26
46
|
init_span_recorder
|
27
47
|
end
|
28
48
|
|
49
|
+
# Initalizes a Transaction instance with a Sentry trace string from another transaction (usually from an external request).
|
50
|
+
#
|
51
|
+
# The original transaction will become the parent of the new Transaction instance. And they will share the same `trace_id`.
|
52
|
+
#
|
53
|
+
# The child transaction will also store the parent's sampling decision in its `parent_sampled` attribute.
|
54
|
+
# @param sentry_trace [String] the trace string from the previous transaction.
|
55
|
+
# @param hub [Hub] the hub that'll be responsible for sending this transaction when it's finished.
|
56
|
+
# @param options [Hash] the options you want to use to initialize a Transaction instance.
|
57
|
+
# @return [Transaction, nil]
|
29
58
|
def self.from_sentry_trace(sentry_trace, hub: Sentry.get_current_hub, **options)
|
30
59
|
return unless hub.configuration.tracing_enabled?
|
31
60
|
return unless sentry_trace
|
@@ -44,12 +73,14 @@ module Sentry
|
|
44
73
|
new(trace_id: trace_id, parent_span_id: parent_span_id, parent_sampled: parent_sampled, hub: hub, **options)
|
45
74
|
end
|
46
75
|
|
76
|
+
# @return [Hash]
|
47
77
|
def to_hash
|
48
78
|
hash = super
|
49
79
|
hash.merge!(name: @name, sampled: @sampled, parent_sampled: @parent_sampled)
|
50
80
|
hash
|
51
81
|
end
|
52
82
|
|
83
|
+
# @return [Transaction]
|
53
84
|
def deep_dup
|
54
85
|
copy = super
|
55
86
|
copy.init_span_recorder(@span_recorder.max_length)
|
@@ -63,23 +94,24 @@ module Sentry
|
|
63
94
|
copy
|
64
95
|
end
|
65
96
|
|
97
|
+
# Sets initial sampling decision of the transaction.
|
98
|
+
# @param sampling_context [Hash] a context Hash that'll be passed to `traces_sampler` (if provided).
|
99
|
+
# @return [void]
|
66
100
|
def set_initial_sample_decision(sampling_context:)
|
67
|
-
unless
|
101
|
+
unless @tracing_enabled
|
68
102
|
@sampled = false
|
69
103
|
return
|
70
104
|
end
|
71
105
|
|
72
106
|
return unless @sampled.nil?
|
73
107
|
|
74
|
-
traces_sampler = configuration.traces_sampler
|
75
|
-
|
76
108
|
sample_rate =
|
77
|
-
if traces_sampler.is_a?(Proc)
|
78
|
-
traces_sampler.call(sampling_context)
|
109
|
+
if @traces_sampler.is_a?(Proc)
|
110
|
+
@traces_sampler.call(sampling_context)
|
79
111
|
elsif !sampling_context[:parent_sampled].nil?
|
80
112
|
sampling_context[:parent_sampled]
|
81
113
|
else
|
82
|
-
|
114
|
+
@traces_sample_rate
|
83
115
|
end
|
84
116
|
|
85
117
|
transaction_description = generate_transaction_description
|
@@ -111,6 +143,9 @@ module Sentry
|
|
111
143
|
end
|
112
144
|
end
|
113
145
|
|
146
|
+
# Finishes the transaction's recording and send it to Sentry.
|
147
|
+
# @param hub [Hub] the hub that'll send this transaction. (Deprecated)
|
148
|
+
# @return [TransactionEvent]
|
114
149
|
def finish(hub: nil)
|
115
150
|
if hub
|
116
151
|
log_warn(
|
@@ -16,17 +16,25 @@ module Sentry
|
|
16
16
|
attr_writer(*WRITER_ATTRIBUTES)
|
17
17
|
attr_reader(*SERIALIZEABLE_ATTRIBUTES)
|
18
18
|
|
19
|
+
# @return [<Array[Span]>]
|
19
20
|
attr_accessor :spans
|
20
21
|
|
22
|
+
# @param configuration [Configuration]
|
23
|
+
# @param integration_meta [Hash, nil]
|
24
|
+
# @param message [String, nil]
|
21
25
|
def initialize(configuration:, integration_meta: nil, message: nil)
|
22
26
|
super
|
23
27
|
@type = TYPE
|
24
28
|
end
|
25
29
|
|
30
|
+
# Sets the event's start_timestamp.
|
31
|
+
# @param time [Time, Float]
|
32
|
+
# @return [void]
|
26
33
|
def start_timestamp=(time)
|
27
34
|
@start_timestamp = time.is_a?(Time) ? time.to_f : time
|
28
35
|
end
|
29
36
|
|
37
|
+
# @return [Hash]
|
30
38
|
def to_hash
|
31
39
|
data = super
|
32
40
|
data[:spans] = @spans.map(&:to_hash) if @spans
|
@@ -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
|