sentry-ruby 6.3.0 → 6.3.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/rack/capture_exceptions.rb +5 -1
- data/lib/sentry/scope.rb +19 -14
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +32 -0
- data/sentry-ruby.gemspec +1 -0
- metadata +20 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 647044ccdd8924b2fb1624eca16311ee75855ff8faaf698e8c29b4583b34b0e2
|
|
4
|
+
data.tar.gz: d214dacdee8ac12cf8d6d18844ddc35fce588ed2ad2bd5299945ebc4f342ed00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9bff18970cb7b9c4db570fa833b47933ce107c327aa260ba7612d1926329215d56c36349d187d998e1badf66f1089abbd477318dddd1975453d361bf7e7e242
|
|
7
|
+
data.tar.gz: 6ab13dae0fa67266128b9c5813b9e20dfa3e96d6852aae2179b0506a85b51947bb2650ec607784aaf9c20adb0469b2bce38c2ec14ef216f8dd85fa669809690d
|
|
@@ -33,7 +33,7 @@ module Sentry
|
|
|
33
33
|
raise # Don't capture Sentry errors
|
|
34
34
|
rescue Exception => e
|
|
35
35
|
capture_exception(e, env)
|
|
36
|
-
finish_transaction(transaction,
|
|
36
|
+
finish_transaction(transaction, status_code_for_exception(e))
|
|
37
37
|
raise
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -86,6 +86,10 @@ module Sentry
|
|
|
86
86
|
def mechanism
|
|
87
87
|
Sentry::Mechanism.new(type: MECHANISM_TYPE, handled: false)
|
|
88
88
|
end
|
|
89
|
+
|
|
90
|
+
def status_code_for_exception(exception)
|
|
91
|
+
500
|
|
92
|
+
end
|
|
89
93
|
end
|
|
90
94
|
end
|
|
91
95
|
end
|
data/lib/sentry/scope.rb
CHANGED
|
@@ -60,19 +60,10 @@ module Sentry
|
|
|
60
60
|
event.attachments = attachments
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
event.dynamic_sampling_context ||= span.get_dynamic_sampling_context
|
|
68
|
-
end
|
|
69
|
-
else
|
|
70
|
-
event.contexts[:trace] ||= propagation_context.get_trace_context
|
|
71
|
-
|
|
72
|
-
if event.respond_to?(:dynamic_sampling_context)
|
|
73
|
-
event.dynamic_sampling_context ||= propagation_context.get_dynamic_sampling_context
|
|
74
|
-
end
|
|
75
|
-
end
|
|
63
|
+
trace_context = get_trace_context
|
|
64
|
+
dynamic_sampling_context = trace_context.delete(:dynamic_sampling_context)
|
|
65
|
+
event.contexts[:trace] ||= trace_context
|
|
66
|
+
event.dynamic_sampling_context ||= dynamic_sampling_context
|
|
76
67
|
|
|
77
68
|
all_event_processors = self.class.global_event_processors + @event_processors
|
|
78
69
|
|
|
@@ -94,7 +85,7 @@ module Sentry
|
|
|
94
85
|
# @return [MetricEvent, LogEvent] the telemetry event with scope context applied
|
|
95
86
|
def apply_to_telemetry(telemetry)
|
|
96
87
|
# TODO-neel when new scope set_attribute api is added: add them here
|
|
97
|
-
trace_context =
|
|
88
|
+
trace_context = get_trace_context
|
|
98
89
|
telemetry.trace_id = trace_context[:trace_id]
|
|
99
90
|
telemetry.span_id = trace_context[:span_id]
|
|
100
91
|
|
|
@@ -305,6 +296,20 @@ module Sentry
|
|
|
305
296
|
span
|
|
306
297
|
end
|
|
307
298
|
|
|
299
|
+
# Returns the trace context for this scope.
|
|
300
|
+
# Prioritizes external propagation context (from OTel) over local propagation context.
|
|
301
|
+
# @return [Hash]
|
|
302
|
+
def get_trace_context
|
|
303
|
+
if span
|
|
304
|
+
span.get_trace_context.merge(dynamic_sampling_context: span.get_dynamic_sampling_context)
|
|
305
|
+
elsif (external_context = Sentry.get_external_propagation_context)
|
|
306
|
+
trace_id, span_id = external_context
|
|
307
|
+
{ trace_id: trace_id, span_id: span_id }
|
|
308
|
+
else
|
|
309
|
+
propagation_context.get_trace_context.merge(dynamic_sampling_context: propagation_context.get_dynamic_sampling_context)
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
308
313
|
# Sets the scope's fingerprint attribute.
|
|
309
314
|
# @param fingerprint [Array]
|
|
310
315
|
# @return [Array]
|
data/lib/sentry/version.rb
CHANGED
data/lib/sentry-ruby.rb
CHANGED
|
@@ -666,6 +666,38 @@ module Sentry
|
|
|
666
666
|
META
|
|
667
667
|
end
|
|
668
668
|
|
|
669
|
+
# Registers a callback function that retrieves the current external propagation context.
|
|
670
|
+
# This is used by OpenTelemetry integration to provide trace_id and span_id from OTel context.
|
|
671
|
+
#
|
|
672
|
+
# @param callback [Proc, nil] A callable that returns [trace_id, span_id] or nil
|
|
673
|
+
# @return [void]
|
|
674
|
+
#
|
|
675
|
+
# @example
|
|
676
|
+
# Sentry.register_external_propagation_context do
|
|
677
|
+
# span_context = OpenTelemetry::Trace.current_span.context
|
|
678
|
+
# return nil unless span_context.valid?
|
|
679
|
+
# [span_context.hex_trace_id, span_context.hex_span_id]
|
|
680
|
+
# end
|
|
681
|
+
def register_external_propagation_context(&callback)
|
|
682
|
+
@external_propagation_context_callback = callback
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
# Returns the external propagation context (trace_id, span_id) if a callback is registered.
|
|
686
|
+
#
|
|
687
|
+
# @return [Array<String>, nil] A tuple of [trace_id, span_id] or nil if no context is available
|
|
688
|
+
def get_external_propagation_context
|
|
689
|
+
return nil unless @external_propagation_context_callback
|
|
690
|
+
|
|
691
|
+
@external_propagation_context_callback.call
|
|
692
|
+
rescue => e
|
|
693
|
+
sdk_logger&.debug(LOGGER_PROGNAME) { "Error getting external propagation context: #{e.message}" } if initialized?
|
|
694
|
+
nil
|
|
695
|
+
end
|
|
696
|
+
|
|
697
|
+
def clear_external_propagation_context
|
|
698
|
+
@external_propagation_context_callback = nil
|
|
699
|
+
end
|
|
700
|
+
|
|
669
701
|
# @!visibility private
|
|
670
702
|
def utc_now
|
|
671
703
|
Time.now.utc
|
data/sentry-ruby.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sentry-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.3.
|
|
4
|
+
version: 6.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sentry Team
|
|
@@ -43,6 +43,20 @@ dependencies:
|
|
|
43
43
|
- - ">="
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
45
|
version: '0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: logger
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
type: :runtime
|
|
54
|
+
prerelease: false
|
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
46
60
|
description: A gem that provides a client interface for the Sentry error logger
|
|
47
61
|
email: accounts@sentry.io
|
|
48
62
|
executables: []
|
|
@@ -155,15 +169,15 @@ files:
|
|
|
155
169
|
- lib/sentry/version.rb
|
|
156
170
|
- sentry-ruby-core.gemspec
|
|
157
171
|
- sentry-ruby.gemspec
|
|
158
|
-
homepage: https://github.com/getsentry/sentry-ruby/tree/6.3.
|
|
172
|
+
homepage: https://github.com/getsentry/sentry-ruby/tree/6.3.1/sentry-ruby
|
|
159
173
|
licenses:
|
|
160
174
|
- MIT
|
|
161
175
|
metadata:
|
|
162
|
-
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/6.3.
|
|
163
|
-
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/6.3.
|
|
164
|
-
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/6.3.
|
|
176
|
+
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/6.3.1/sentry-ruby
|
|
177
|
+
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/6.3.1/sentry-ruby
|
|
178
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/6.3.1/CHANGELOG.md
|
|
165
179
|
bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
|
|
166
|
-
documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/6.3.
|
|
180
|
+
documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/6.3.1
|
|
167
181
|
rdoc_options: []
|
|
168
182
|
require_paths:
|
|
169
183
|
- lib
|