sentry-ruby 5.5.0 → 5.10.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/.rspec +0 -1
- data/Gemfile +14 -5
- data/README.md +3 -0
- data/Rakefile +8 -1
- data/lib/sentry/backtrace.rb +1 -1
- data/lib/sentry/baggage.rb +1 -12
- data/lib/sentry/client.rb +14 -1
- data/lib/sentry/configuration.rb +128 -26
- data/lib/sentry/envelope.rb +1 -4
- data/lib/sentry/hub.rb +31 -3
- data/lib/sentry/interfaces/request.rb +2 -14
- data/lib/sentry/interfaces/single_exception.rb +9 -1
- data/lib/sentry/net/http.rb +20 -37
- data/lib/sentry/profiler.rb +222 -0
- data/lib/sentry/puma.rb +25 -0
- data/lib/sentry/rack/capture_exceptions.rb +1 -1
- data/lib/sentry/redis.rb +36 -23
- data/lib/sentry/scope.rb +26 -3
- data/lib/sentry/span.rb +14 -11
- data/lib/sentry/test_helper.rb +1 -1
- data/lib/sentry/transaction.rb +73 -15
- data/lib/sentry/transaction_event.rb +36 -0
- data/lib/sentry/transport.rb +7 -0
- data/lib/sentry/utils/argument_checking_helper.rb +3 -3
- data/lib/sentry/utils/encoding_helper.rb +22 -0
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +35 -20
- metadata +5 -3
- data/CODE_OF_CONDUCT.md +0 -74
@@ -11,22 +11,32 @@ module Sentry
|
|
11
11
|
# @return [Hash, nil]
|
12
12
|
attr_accessor :dynamic_sampling_context
|
13
13
|
|
14
|
+
# @return [Hash]
|
15
|
+
attr_accessor :measurements
|
16
|
+
|
14
17
|
# @return [Float, nil]
|
15
18
|
attr_reader :start_timestamp
|
16
19
|
|
20
|
+
# @return [Hash, nil]
|
21
|
+
attr_accessor :profile
|
22
|
+
|
17
23
|
def initialize(transaction:, **options)
|
18
24
|
super(**options)
|
19
25
|
|
20
26
|
self.transaction = transaction.name
|
21
27
|
self.transaction_info = { source: transaction.source }
|
28
|
+
self.contexts.merge!(transaction.contexts)
|
22
29
|
self.contexts.merge!(trace: transaction.get_trace_context)
|
23
30
|
self.timestamp = transaction.timestamp
|
24
31
|
self.start_timestamp = transaction.start_timestamp
|
25
32
|
self.tags = transaction.tags
|
26
33
|
self.dynamic_sampling_context = transaction.get_baggage.dynamic_sampling_context
|
34
|
+
self.measurements = transaction.measurements
|
27
35
|
|
28
36
|
finished_spans = transaction.span_recorder.spans.select { |span| span.timestamp && span != transaction }
|
29
37
|
self.spans = finished_spans.map(&:to_hash)
|
38
|
+
|
39
|
+
populate_profile(transaction)
|
30
40
|
end
|
31
41
|
|
32
42
|
# Sets the event's start_timestamp.
|
@@ -41,7 +51,33 @@ module Sentry
|
|
41
51
|
data = super
|
42
52
|
data[:spans] = @spans.map(&:to_hash) if @spans
|
43
53
|
data[:start_timestamp] = @start_timestamp
|
54
|
+
data[:measurements] = @measurements
|
44
55
|
data
|
45
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def populate_profile(transaction)
|
61
|
+
profile_hash = transaction.profiler.to_hash
|
62
|
+
return if profile_hash.empty?
|
63
|
+
|
64
|
+
profile_hash.merge!(
|
65
|
+
environment: environment,
|
66
|
+
release: release,
|
67
|
+
timestamp: Time.at(start_timestamp).iso8601,
|
68
|
+
device: { architecture: Scope.os_context[:machine] },
|
69
|
+
os: { name: Scope.os_context[:name], version: Scope.os_context[:version] },
|
70
|
+
runtime: Scope.runtime_context,
|
71
|
+
transaction: {
|
72
|
+
id: event_id,
|
73
|
+
name: transaction.name,
|
74
|
+
trace_id: transaction.trace_id,
|
75
|
+
# TODO-neel-profiler stubbed for now, see thread_id note in profiler.rb
|
76
|
+
active_thead_id: '0'
|
77
|
+
}
|
78
|
+
)
|
79
|
+
|
80
|
+
self.profile = profile_hash
|
81
|
+
end
|
46
82
|
end
|
47
83
|
end
|
data/lib/sentry/transport.rb
CHANGED
@@ -154,6 +154,13 @@ module Sentry
|
|
154
154
|
event_payload
|
155
155
|
)
|
156
156
|
|
157
|
+
if event.is_a?(TransactionEvent) && event.profile
|
158
|
+
envelope.add_item(
|
159
|
+
{ type: 'profile', content_type: 'application/json' },
|
160
|
+
event.profile
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
157
164
|
client_report_headers, client_report_payload = fetch_pending_client_report
|
158
165
|
envelope.add_item(client_report_headers, client_report_payload) if client_report_headers
|
159
166
|
|
@@ -4,9 +4,9 @@ module Sentry
|
|
4
4
|
module ArgumentCheckingHelper
|
5
5
|
private
|
6
6
|
|
7
|
-
def check_argument_type!(argument,
|
8
|
-
unless argument.is_a?(
|
9
|
-
raise ArgumentError, "expect the argument to be a #{
|
7
|
+
def check_argument_type!(argument, *expected_types)
|
8
|
+
unless expected_types.any? { |t| argument.is_a?(t) }
|
9
|
+
raise ArgumentError, "expect the argument to be a #{expected_types.join(' or ')}, got #{argument.class} (#{argument.inspect})"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sentry
|
4
|
+
module Utils
|
5
|
+
module EncodingHelper
|
6
|
+
def self.encode_to_utf_8(value)
|
7
|
+
if value.encoding != Encoding::UTF_8 && value.respond_to?(:force_encoding)
|
8
|
+
value = value.dup.force_encoding(Encoding::UTF_8)
|
9
|
+
end
|
10
|
+
|
11
|
+
value = value.scrub unless value.valid_encoding?
|
12
|
+
value
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.valid_utf_8?(value)
|
16
|
+
return true unless value.respond_to?(:force_encoding)
|
17
|
+
|
18
|
+
value.dup.force_encoding(Encoding::UTF_8).valid_encoding?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/sentry/version.rb
CHANGED
data/lib/sentry-ruby.rb
CHANGED
@@ -8,6 +8,7 @@ require "sentry/version"
|
|
8
8
|
require "sentry/exceptions"
|
9
9
|
require "sentry/core_ext/object/deep_dup"
|
10
10
|
require "sentry/utils/argument_checking_helper"
|
11
|
+
require "sentry/utils/encoding_helper"
|
11
12
|
require "sentry/utils/logging_helper"
|
12
13
|
require "sentry/configuration"
|
13
14
|
require "sentry/logger"
|
@@ -72,8 +73,18 @@ module Sentry
|
|
72
73
|
##### Patch Registration #####
|
73
74
|
|
74
75
|
# @!visibility private
|
75
|
-
def register_patch(&block)
|
76
|
-
|
76
|
+
def register_patch(patch = nil, target = nil, &block)
|
77
|
+
if patch && block
|
78
|
+
raise ArgumentError.new("Please provide either a patch and its target OR a block, but not both")
|
79
|
+
end
|
80
|
+
|
81
|
+
if block
|
82
|
+
registered_patches << block
|
83
|
+
else
|
84
|
+
registered_patches << proc do
|
85
|
+
target.send(:prepend, patch) unless target.ancestors.include?(patch)
|
86
|
+
end
|
87
|
+
end
|
77
88
|
end
|
78
89
|
|
79
90
|
# @!visibility private
|
@@ -211,7 +222,7 @@ module Sentry
|
|
211
222
|
nil
|
212
223
|
end
|
213
224
|
|
214
|
-
if config.
|
225
|
+
if config.include_local_variables
|
215
226
|
exception_locals_tp.enable
|
216
227
|
end
|
217
228
|
|
@@ -233,7 +244,7 @@ module Sentry
|
|
233
244
|
@session_flusher = nil
|
234
245
|
end
|
235
246
|
|
236
|
-
if configuration&.
|
247
|
+
if configuration&.include_local_variables
|
237
248
|
exception_locals_tp.disable
|
238
249
|
end
|
239
250
|
|
@@ -441,22 +452,8 @@ module Sentry
|
|
441
452
|
# end
|
442
453
|
#
|
443
454
|
def with_child_span(**attributes, &block)
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
begin
|
448
|
-
current_span.with_child_span(**attributes) do |child_span|
|
449
|
-
get_current_scope.set_span(child_span)
|
450
|
-
result = yield(child_span)
|
451
|
-
end
|
452
|
-
ensure
|
453
|
-
get_current_scope.set_span(current_span)
|
454
|
-
end
|
455
|
-
|
456
|
-
result
|
457
|
-
else
|
458
|
-
yield(nil)
|
459
|
-
end
|
455
|
+
return yield(nil) unless Sentry.initialized?
|
456
|
+
get_current_hub.with_child_span(**attributes, &block)
|
460
457
|
end
|
461
458
|
|
462
459
|
# Returns the id of the lastly reported Sentry::Event.
|
@@ -475,6 +472,23 @@ module Sentry
|
|
475
472
|
!!exc.instance_variable_get(CAPTURED_SIGNATURE)
|
476
473
|
end
|
477
474
|
|
475
|
+
# Add a global event processor [Proc].
|
476
|
+
# These run before scope event processors.
|
477
|
+
#
|
478
|
+
# @yieldparam event [Event]
|
479
|
+
# @yieldparam hint [Hash, nil]
|
480
|
+
# @return [void]
|
481
|
+
#
|
482
|
+
# @example
|
483
|
+
# Sentry.add_global_event_processor do |event, hint|
|
484
|
+
# event.tags = { foo: 42 }
|
485
|
+
# event
|
486
|
+
# end
|
487
|
+
#
|
488
|
+
def add_global_event_processor(&block)
|
489
|
+
Scope.add_global_event_processor(&block)
|
490
|
+
end
|
491
|
+
|
478
492
|
##### Helpers #####
|
479
493
|
|
480
494
|
# @!visibility private
|
@@ -505,3 +519,4 @@ end
|
|
505
519
|
# patches
|
506
520
|
require "sentry/net/http"
|
507
521
|
require "sentry/redis"
|
522
|
+
require "sentry/puma"
|
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.10.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:
|
11
|
+
date: 2023-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -42,7 +42,6 @@ files:
|
|
42
42
|
- ".rspec"
|
43
43
|
- ".yardopts"
|
44
44
|
- CHANGELOG.md
|
45
|
-
- CODE_OF_CONDUCT.md
|
46
45
|
- Gemfile
|
47
46
|
- LICENSE.txt
|
48
47
|
- Makefile
|
@@ -78,6 +77,8 @@ files:
|
|
78
77
|
- lib/sentry/linecache.rb
|
79
78
|
- lib/sentry/logger.rb
|
80
79
|
- lib/sentry/net/http.rb
|
80
|
+
- lib/sentry/profiler.rb
|
81
|
+
- lib/sentry/puma.rb
|
81
82
|
- lib/sentry/rack.rb
|
82
83
|
- lib/sentry/rack/capture_exceptions.rb
|
83
84
|
- lib/sentry/rake.rb
|
@@ -96,6 +97,7 @@ files:
|
|
96
97
|
- lib/sentry/transport/http_transport.rb
|
97
98
|
- lib/sentry/utils/argument_checking_helper.rb
|
98
99
|
- lib/sentry/utils/custom_inspection.rb
|
100
|
+
- lib/sentry/utils/encoding_helper.rb
|
99
101
|
- lib/sentry/utils/exception_cause_chain.rb
|
100
102
|
- lib/sentry/utils/logging_helper.rb
|
101
103
|
- lib/sentry/utils/real_ip.rb
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at stan001212@gmail.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: https://contributor-covenant.org
|
74
|
-
[version]: https://contributor-covenant.org/version/1/4/
|