sentry-ruby 5.6.0 → 5.7.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/README.md +3 -0
- data/lib/sentry/configuration.rb +11 -0
- data/lib/sentry/hub.rb +5 -2
- data/lib/sentry/span.rb +4 -6
- data/lib/sentry/transaction.rb +43 -13
- data/lib/sentry/transaction_event.rb +1 -0
- data/lib/sentry/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a60b754ccac4d1fd8cf47cd94d8896c46dc8232f87d06132681a19ed223ac14c
|
4
|
+
data.tar.gz: 923f906cd698d18f2fcb419bfeb2d1262c4165e6a8ffe2484de7027a90e69644
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d46f719bd4e0abb6f9fcd254b6e6321c9796c2278bc31fa5f86dc541cc0ce54a4f6cc10078d6d0277c89ff0cd4896e2a0ec0aa04e3052214b01b85cb2aa115c
|
7
|
+
data.tar.gz: 14b28401b32d9ce9ee7ac0351de736d0d9f11221010e61091e4976b71a58b1fef61ca4e282ec31a714e040148197c5fab46f0a0e39e475ea1f6dd0196b5f104d
|
data/README.md
CHANGED
@@ -20,6 +20,7 @@ Sentry SDK for Ruby
|
|
20
20
|
| [](https://rubygems.org/gems/sentry-sidekiq) | [](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_sidekiq_test.yml) | [](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [](https://rubygems.org/gems/sentry-sidekiq/) |
|
21
21
|
| [](https://rubygems.org/gems/sentry-delayed_job) | [](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_delayed_job_test.yml) | [](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [](https://rubygems.org/gems/sentry-delayed_job/) |
|
22
22
|
| [](https://rubygems.org/gems/sentry-resque) | [](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_resque_test.yml) | [](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [](https://rubygems.org/gems/sentry-resque/) |
|
23
|
+
| [](https://rubygems.org/gems/sentry-opentelemetry) | [](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_opentelemetry_test.yml) | [](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [](https://rubygems.org/gems/sentry-opentelemetry/) |
|
23
24
|
|
24
25
|
|
25
26
|
|
@@ -51,6 +52,7 @@ gem "sentry-rails"
|
|
51
52
|
gem "sentry-sidekiq"
|
52
53
|
gem "sentry-delayed_job"
|
53
54
|
gem "sentry-resque"
|
55
|
+
gem "sentry-opentelemetry"
|
54
56
|
```
|
55
57
|
|
56
58
|
### Configuration
|
@@ -88,6 +90,7 @@ To learn more about sampling transactions, please visit the [official documentat
|
|
88
90
|
- [Sidekiq](https://docs.sentry.io/platforms/ruby/guides/sidekiq/)
|
89
91
|
- [DelayedJob](https://docs.sentry.io/platforms/ruby/guides/delayed_job/)
|
90
92
|
- [Resque](https://docs.sentry.io/platforms/ruby/guides/resque/)
|
93
|
+
- [OpenTemeletry](https://docs.sentry.io/platforms/ruby/performance/instrumentation/opentelemetry/)
|
91
94
|
|
92
95
|
### Enriching Events
|
93
96
|
|
data/lib/sentry/configuration.rb
CHANGED
@@ -211,6 +211,10 @@ module Sentry
|
|
211
211
|
# @return [Boolean]
|
212
212
|
attr_accessor :auto_session_tracking
|
213
213
|
|
214
|
+
# The instrumenter to use, :sentry or :otel
|
215
|
+
# @return [Symbol]
|
216
|
+
attr_reader :instrumenter
|
217
|
+
|
214
218
|
# these are not config options
|
215
219
|
# @!visibility private
|
216
220
|
attr_reader :errors, :gem_specs
|
@@ -237,6 +241,8 @@ module Sentry
|
|
237
241
|
MODULE_SEPARATOR = "::".freeze
|
238
242
|
SKIP_INSPECTION_ATTRIBUTES = [:@linecache, :@stacktrace_builder]
|
239
243
|
|
244
|
+
INSTRUMENTERS = [:sentry, :otel]
|
245
|
+
|
240
246
|
# Post initialization callbacks are called at the end of initialization process
|
241
247
|
# allowing extending the configuration of sentry-ruby by multiple extensions
|
242
248
|
@@post_initialization_callbacks = []
|
@@ -269,6 +275,7 @@ module Sentry
|
|
269
275
|
self.trusted_proxies = []
|
270
276
|
self.dsn = ENV['SENTRY_DSN']
|
271
277
|
self.server_name = server_name_from_env
|
278
|
+
self.instrumenter = :sentry
|
272
279
|
|
273
280
|
self.before_send = nil
|
274
281
|
self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT
|
@@ -332,6 +339,10 @@ module Sentry
|
|
332
339
|
@environment = environment.to_s
|
333
340
|
end
|
334
341
|
|
342
|
+
def instrumenter=(instrumenter)
|
343
|
+
@instrumenter = INSTRUMENTERS.include?(instrumenter) ? instrumenter : :sentry
|
344
|
+
end
|
345
|
+
|
335
346
|
def sending_allowed?
|
336
347
|
@errors = []
|
337
348
|
|
data/lib/sentry/hub.rb
CHANGED
@@ -76,8 +76,9 @@ module Sentry
|
|
76
76
|
@stack.pop
|
77
77
|
end
|
78
78
|
|
79
|
-
def start_transaction(transaction: nil, custom_sampling_context: {}, **options)
|
79
|
+
def start_transaction(transaction: nil, custom_sampling_context: {}, instrumenter: :sentry, **options)
|
80
80
|
return unless configuration.tracing_enabled?
|
81
|
+
return unless instrumenter == configuration.instrumenter
|
81
82
|
|
82
83
|
transaction ||= Transaction.new(**options.merge(hub: self))
|
83
84
|
|
@@ -92,7 +93,9 @@ module Sentry
|
|
92
93
|
transaction
|
93
94
|
end
|
94
95
|
|
95
|
-
def with_child_span(**attributes, &block)
|
96
|
+
def with_child_span(instrumenter: :sentry, **attributes, &block)
|
97
|
+
return yield(nil) unless instrumenter == configuration.instrumenter
|
98
|
+
|
96
99
|
current_span = current_scope.get_span
|
97
100
|
return yield(nil) unless current_span
|
98
101
|
|
data/lib/sentry/span.rb
CHANGED
@@ -68,13 +68,14 @@ module Sentry
|
|
68
68
|
op: nil,
|
69
69
|
status: nil,
|
70
70
|
trace_id: nil,
|
71
|
+
span_id: nil,
|
71
72
|
parent_span_id: nil,
|
72
73
|
sampled: nil,
|
73
74
|
start_timestamp: nil,
|
74
75
|
timestamp: nil
|
75
76
|
)
|
76
77
|
@trace_id = trace_id || SecureRandom.uuid.delete("-")
|
77
|
-
@span_id = SecureRandom.hex(8)
|
78
|
+
@span_id = span_id || SecureRandom.hex(8)
|
78
79
|
@parent_span_id = parent_span_id
|
79
80
|
@sampled = sampled
|
80
81
|
@start_timestamp = start_timestamp || Sentry.utc_now.to_f
|
@@ -89,11 +90,8 @@ module Sentry
|
|
89
90
|
|
90
91
|
# Finishes the span by adding a timestamp.
|
91
92
|
# @return [self]
|
92
|
-
def finish
|
93
|
-
|
94
|
-
return if @timestamp
|
95
|
-
|
96
|
-
@timestamp = Sentry.utc_now.to_f
|
93
|
+
def finish(end_timestamp: nil)
|
94
|
+
@timestamp = end_timestamp || @timestamp || Sentry.utc_now.to_f
|
97
95
|
self
|
98
96
|
end
|
99
97
|
|
data/lib/sentry/transaction.rb
CHANGED
@@ -50,6 +50,10 @@ module Sentry
|
|
50
50
|
# @return [Float, nil]
|
51
51
|
attr_reader :effective_sample_rate
|
52
52
|
|
53
|
+
# Additional contexts stored directly on the transaction object.
|
54
|
+
# @return [Hash]
|
55
|
+
attr_reader :contexts
|
56
|
+
|
53
57
|
def initialize(
|
54
58
|
hub:,
|
55
59
|
name: nil,
|
@@ -60,8 +64,7 @@ module Sentry
|
|
60
64
|
)
|
61
65
|
super(transaction: self, **options)
|
62
66
|
|
63
|
-
|
64
|
-
@source = SOURCES.include?(source) ? source.to_sym : :custom
|
67
|
+
set_name(name, source: source)
|
65
68
|
@parent_sampled = parent_sampled
|
66
69
|
@hub = hub
|
67
70
|
@baggage = baggage
|
@@ -74,6 +77,7 @@ module Sentry
|
|
74
77
|
@environment = hub.configuration.environment
|
75
78
|
@dsn = hub.configuration.dsn
|
76
79
|
@effective_sample_rate = nil
|
80
|
+
@contexts = {}
|
77
81
|
init_span_recorder
|
78
82
|
end
|
79
83
|
|
@@ -91,16 +95,10 @@ module Sentry
|
|
91
95
|
return unless hub.configuration.tracing_enabled?
|
92
96
|
return unless sentry_trace
|
93
97
|
|
94
|
-
|
95
|
-
return
|
96
|
-
trace_id, parent_span_id, sampled_flag = match[1..3]
|
98
|
+
sentry_trace_data = extract_sentry_trace(sentry_trace)
|
99
|
+
return unless sentry_trace_data
|
97
100
|
|
98
|
-
parent_sampled =
|
99
|
-
if sampled_flag.nil?
|
100
|
-
nil
|
101
|
-
else
|
102
|
-
sampled_flag != "0"
|
103
|
-
end
|
101
|
+
trace_id, parent_span_id, parent_sampled = sentry_trace_data
|
104
102
|
|
105
103
|
baggage = if baggage && !baggage.empty?
|
106
104
|
Baggage.from_incoming_header(baggage)
|
@@ -123,6 +121,20 @@ module Sentry
|
|
123
121
|
)
|
124
122
|
end
|
125
123
|
|
124
|
+
# Extract the trace_id, parent_span_id and parent_sampled values from a sentry-trace header.
|
125
|
+
#
|
126
|
+
# @param sentry_trace [String] the sentry-trace header value from the previous transaction.
|
127
|
+
# @return [Array, nil]
|
128
|
+
def self.extract_sentry_trace(sentry_trace)
|
129
|
+
match = SENTRY_TRACE_REGEXP.match(sentry_trace)
|
130
|
+
return nil if match.nil?
|
131
|
+
|
132
|
+
trace_id, parent_span_id, sampled_flag = match[1..3]
|
133
|
+
parent_sampled = sampled_flag.nil? ? nil : sampled_flag != "0"
|
134
|
+
|
135
|
+
[trace_id, parent_span_id, parent_sampled]
|
136
|
+
end
|
137
|
+
|
126
138
|
# @return [Hash]
|
127
139
|
def to_hash
|
128
140
|
hash = super
|
@@ -210,7 +222,7 @@ module Sentry
|
|
210
222
|
# Finishes the transaction's recording and send it to Sentry.
|
211
223
|
# @param hub [Hub] the hub that'll send this transaction. (Deprecated)
|
212
224
|
# @return [TransactionEvent]
|
213
|
-
def finish(hub: nil)
|
225
|
+
def finish(hub: nil, end_timestamp: nil)
|
214
226
|
if hub
|
215
227
|
log_warn(
|
216
228
|
<<~MSG
|
@@ -222,7 +234,7 @@ module Sentry
|
|
222
234
|
|
223
235
|
hub ||= @hub
|
224
236
|
|
225
|
-
super()
|
237
|
+
super(end_timestamp: end_timestamp)
|
226
238
|
|
227
239
|
if @name.nil?
|
228
240
|
@name = UNLABELD_NAME
|
@@ -244,6 +256,24 @@ module Sentry
|
|
244
256
|
@baggage
|
245
257
|
end
|
246
258
|
|
259
|
+
# Set the transaction name directly.
|
260
|
+
# Considered internal api since it bypasses the usual scope logic.
|
261
|
+
# @param name [String]
|
262
|
+
# @param source [Symbol]
|
263
|
+
# @return [void]
|
264
|
+
def set_name(name, source: :custom)
|
265
|
+
@name = name
|
266
|
+
@source = SOURCES.include?(source) ? source.to_sym : :custom
|
267
|
+
end
|
268
|
+
|
269
|
+
# Set contexts directly on the transaction.
|
270
|
+
# @param key [String, Symbol]
|
271
|
+
# @param value [Object]
|
272
|
+
# @return [void]
|
273
|
+
def set_context(key, value)
|
274
|
+
@contexts[key] = value
|
275
|
+
end
|
276
|
+
|
247
277
|
protected
|
248
278
|
|
249
279
|
def init_span_recorder(limit = 1000)
|
@@ -19,6 +19,7 @@ module Sentry
|
|
19
19
|
|
20
20
|
self.transaction = transaction.name
|
21
21
|
self.transaction_info = { source: transaction.source }
|
22
|
+
self.contexts.merge!(transaction.contexts)
|
22
23
|
self.contexts.merge!(trace: transaction.get_trace_context)
|
23
24
|
self.timestamp = transaction.timestamp
|
24
25
|
self.start_timestamp = transaction.start_timestamp
|
data/lib/sentry/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|