sentry-ruby 5.10.0 → 5.14.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/Gemfile +7 -1
- data/README.md +9 -9
- data/lib/sentry/breadcrumb.rb +8 -2
- data/lib/sentry/check_in_event.rb +60 -0
- data/lib/sentry/client.rb +36 -1
- data/lib/sentry/configuration.rb +16 -0
- data/lib/sentry/cron/monitor_check_ins.rb +66 -0
- data/lib/sentry/cron/monitor_config.rb +53 -0
- data/lib/sentry/cron/monitor_schedule.rb +42 -0
- data/lib/sentry/envelope.rb +1 -1
- data/lib/sentry/event.rb +6 -0
- data/lib/sentry/hub.rb +69 -1
- data/lib/sentry/integrable.rb +6 -0
- data/lib/sentry/interfaces/single_exception.rb +5 -3
- data/lib/sentry/net/http.rb +25 -22
- data/lib/sentry/profiler.rb +18 -7
- data/lib/sentry/propagation_context.rb +134 -0
- data/lib/sentry/puma.rb +11 -4
- data/lib/sentry/rack/capture_exceptions.rb +1 -4
- data/lib/sentry/redis.rb +8 -3
- data/lib/sentry/release_detector.rb +1 -1
- data/lib/sentry/scope.rb +17 -2
- data/lib/sentry/span.rb +39 -2
- data/lib/sentry/test_helper.rb +18 -12
- data/lib/sentry/transaction.rb +9 -17
- data/lib/sentry/transaction_event.rb +0 -3
- data/lib/sentry/transport/configuration.rb +74 -1
- data/lib/sentry/transport/http_transport.rb +8 -2
- data/lib/sentry/transport.rb +4 -3
- data/lib/sentry/utils/argument_checking_helper.rb +6 -0
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +62 -6
- metadata +7 -2
@@ -3,7 +3,80 @@
|
|
3
3
|
module Sentry
|
4
4
|
class Transport
|
5
5
|
class Configuration
|
6
|
-
|
6
|
+
|
7
|
+
# The timeout in seconds to open a connection to Sentry, in seconds.
|
8
|
+
# Default value is 2.
|
9
|
+
#
|
10
|
+
# @return [Integer]
|
11
|
+
attr_accessor :timeout
|
12
|
+
|
13
|
+
# The timeout in seconds to read data from Sentry, in seconds.
|
14
|
+
# Default value is 1.
|
15
|
+
#
|
16
|
+
# @return [Integer]
|
17
|
+
attr_accessor :open_timeout
|
18
|
+
|
19
|
+
# The proxy configuration to use to connect to Sentry.
|
20
|
+
# Accepts either a URI formatted string, URI, or a hash with the `uri`,
|
21
|
+
# `user`, and `password` keys.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# # setup proxy using a string:
|
25
|
+
# config.transport.proxy = "https://user:password@proxyhost:8080"
|
26
|
+
#
|
27
|
+
# # setup proxy using a URI:
|
28
|
+
# config.transport.proxy = URI("https://user:password@proxyhost:8080")
|
29
|
+
#
|
30
|
+
# # setup proxy using a hash:
|
31
|
+
# config.transport.proxy = {
|
32
|
+
# uri: URI("https://proxyhost:8080"),
|
33
|
+
# user: "user",
|
34
|
+
# password: "password"
|
35
|
+
# }
|
36
|
+
#
|
37
|
+
# If you're using the default transport (`Sentry::HTTPTransport`),
|
38
|
+
# proxy settings will also automatically be read from tne environment
|
39
|
+
# variables (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`).
|
40
|
+
#
|
41
|
+
# @return [String, URI, Hash, nil]
|
42
|
+
attr_accessor :proxy
|
43
|
+
|
44
|
+
# The SSL configuration to use to connect to Sentry.
|
45
|
+
# You can either pass a `Hash` containing `ca_file` and `verification` keys,
|
46
|
+
# or you can set those options directly on the `Sentry::HTTPTransport::Configuration` object:
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# config.transport.ssl = {
|
50
|
+
# ca_file: "/path/to/ca_file",
|
51
|
+
# verification: true
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# @return [Hash, nil]
|
55
|
+
attr_accessor :ssl
|
56
|
+
|
57
|
+
# The path to the CA file to use to verify the SSL connection.
|
58
|
+
# Default value is `nil`.
|
59
|
+
#
|
60
|
+
# @return [String, nil]
|
61
|
+
attr_accessor :ssl_ca_file
|
62
|
+
|
63
|
+
# Whether to verify that the peer certificate is valid in SSL connections.
|
64
|
+
# Default value is `true`.
|
65
|
+
#
|
66
|
+
# @return [Boolean]
|
67
|
+
attr_accessor :ssl_verification
|
68
|
+
|
69
|
+
# The encoding to use to compress the request body.
|
70
|
+
# Default value is `Sentry::HTTPTransport::GZIP_ENCODING`.
|
71
|
+
#
|
72
|
+
# @return [String]
|
73
|
+
attr_accessor :encoding
|
74
|
+
|
75
|
+
# The class to use as a transport to connect to Sentry.
|
76
|
+
# If this option not set, it will return `nil`, and Sentry will use
|
77
|
+
# `Sentry::HTTPTransport` by default.
|
78
|
+
#
|
79
|
+
# @return [Class, nil]
|
7
80
|
attr_reader :transport_class
|
8
81
|
|
9
82
|
def initialize
|
@@ -128,12 +128,15 @@ module Sentry
|
|
128
128
|
|
129
129
|
def conn
|
130
130
|
server = URI(@dsn.server)
|
131
|
-
|
131
|
+
|
132
|
+
# connection respects proxy setting from @transport_configuration, or environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY)
|
133
|
+
# Net::HTTP will automatically read the env vars.
|
134
|
+
# See https://ruby-doc.org/3.2.2/stdlibs/net/Net/HTTP.html#class-Net::HTTP-label-Proxies
|
132
135
|
connection =
|
133
136
|
if proxy = normalize_proxy(@transport_configuration.proxy)
|
134
137
|
::Net::HTTP.new(server.hostname, server.port, proxy[:uri].hostname, proxy[:uri].port, proxy[:user], proxy[:password])
|
135
138
|
else
|
136
|
-
::Net::HTTP.new(server.hostname, server.port
|
139
|
+
::Net::HTTP.new(server.hostname, server.port)
|
137
140
|
end
|
138
141
|
|
139
142
|
connection.use_ssl = server.scheme == "https"
|
@@ -148,6 +151,9 @@ module Sentry
|
|
148
151
|
connection
|
149
152
|
end
|
150
153
|
|
154
|
+
# @param proxy [String, URI, Hash] Proxy config value passed into `config.transport`.
|
155
|
+
# Accepts either a URI formatted string, URI, or a hash with the `uri`, `user`, and `password` keys.
|
156
|
+
# @return [Hash] Normalized proxy config that will be passed into `Net::HTTP`
|
151
157
|
def normalize_proxy(proxy)
|
152
158
|
return proxy unless proxy
|
153
159
|
|
data/lib/sentry/transport.rb
CHANGED
@@ -18,7 +18,8 @@ module Sentry
|
|
18
18
|
:network_error,
|
19
19
|
:sample_rate,
|
20
20
|
:before_send,
|
21
|
-
:event_processor
|
21
|
+
:event_processor,
|
22
|
+
:insufficient_data
|
22
23
|
]
|
23
24
|
|
24
25
|
include LoggingHelper
|
@@ -143,7 +144,7 @@ module Sentry
|
|
143
144
|
sent_at: Sentry.utc_now.iso8601
|
144
145
|
}
|
145
146
|
|
146
|
-
if event.is_a?(
|
147
|
+
if event.is_a?(Event) && event.dynamic_sampling_context
|
147
148
|
envelope_headers[:trace] = event.dynamic_sampling_context
|
148
149
|
end
|
149
150
|
|
@@ -185,7 +186,7 @@ module Sentry
|
|
185
186
|
reason, type = key
|
186
187
|
|
187
188
|
# 'event' has to be mapped to 'error'
|
188
|
-
category = type == '
|
189
|
+
category = type == 'event' ? 'error' : type
|
189
190
|
|
190
191
|
{ reason: reason, category: category, quantity: val }
|
191
192
|
end
|
@@ -9,5 +9,11 @@ module Sentry
|
|
9
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
|
+
|
13
|
+
def check_argument_includes!(argument, values)
|
14
|
+
unless values.include?(argument)
|
15
|
+
raise ArgumentError, "expect the argument to be one of #{values.map(&:inspect).join(' or ')}, got #{argument.inspect}"
|
16
|
+
end
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
data/lib/sentry/version.rb
CHANGED
data/lib/sentry-ruby.rb
CHANGED
@@ -15,11 +15,13 @@ require "sentry/logger"
|
|
15
15
|
require "sentry/event"
|
16
16
|
require "sentry/error_event"
|
17
17
|
require "sentry/transaction_event"
|
18
|
+
require "sentry/check_in_event"
|
18
19
|
require "sentry/span"
|
19
20
|
require "sentry/transaction"
|
20
21
|
require "sentry/hub"
|
21
22
|
require "sentry/background_worker"
|
22
23
|
require "sentry/session_flusher"
|
24
|
+
require "sentry/cron/monitor_check_ins"
|
23
25
|
|
24
26
|
[
|
25
27
|
"sentry/rake",
|
@@ -73,15 +75,15 @@ module Sentry
|
|
73
75
|
##### Patch Registration #####
|
74
76
|
|
75
77
|
# @!visibility private
|
76
|
-
def register_patch(patch = nil, target = nil, &block)
|
78
|
+
def register_patch(key, patch = nil, target = nil, &block)
|
77
79
|
if patch && block
|
78
80
|
raise ArgumentError.new("Please provide either a patch and its target OR a block, but not both")
|
79
81
|
end
|
80
82
|
|
81
83
|
if block
|
82
|
-
registered_patches
|
84
|
+
registered_patches[key] = block
|
83
85
|
else
|
84
|
-
registered_patches
|
86
|
+
registered_patches[key] = proc do
|
85
87
|
target.send(:prepend, patch) unless target.ancestors.include?(patch)
|
86
88
|
end
|
87
89
|
end
|
@@ -89,14 +91,14 @@ module Sentry
|
|
89
91
|
|
90
92
|
# @!visibility private
|
91
93
|
def apply_patches(config)
|
92
|
-
registered_patches.each do |patch|
|
93
|
-
patch.call(config)
|
94
|
+
registered_patches.each do |key, patch|
|
95
|
+
patch.call(config) if config.enabled_patches.include?(key)
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|
97
99
|
# @!visibility private
|
98
100
|
def registered_patches
|
99
|
-
@registered_patches ||=
|
101
|
+
@registered_patches ||= {}
|
100
102
|
end
|
101
103
|
|
102
104
|
##### Integrations #####
|
@@ -430,6 +432,24 @@ module Sentry
|
|
430
432
|
get_current_hub.capture_event(event)
|
431
433
|
end
|
432
434
|
|
435
|
+
# Captures a check-in and sends it to Sentry via the currently active hub.
|
436
|
+
#
|
437
|
+
# @param slug [String] identifier of this monitor
|
438
|
+
# @param status [Symbol] status of this check-in, one of {CheckInEvent::VALID_STATUSES}
|
439
|
+
#
|
440
|
+
# @param [Hash] options extra check-in options
|
441
|
+
# @option options [String] check_in_id for updating the status of an existing monitor
|
442
|
+
# @option options [Integer] duration seconds elapsed since this monitor started
|
443
|
+
# @option options [Cron::MonitorConfig] monitor_config configuration for this monitor
|
444
|
+
#
|
445
|
+
# @yieldparam scope [Scope]
|
446
|
+
#
|
447
|
+
# @return [String, nil] The {CheckInEvent#check_in_id} to use for later updates on the same slug
|
448
|
+
def capture_check_in(slug, status, **options, &block)
|
449
|
+
return unless initialized?
|
450
|
+
get_current_hub.capture_check_in(slug, status, **options, &block)
|
451
|
+
end
|
452
|
+
|
433
453
|
# Takes or initializes a new Sentry::Transaction and makes a sampling decision for it.
|
434
454
|
#
|
435
455
|
# @return [Transaction, nil]
|
@@ -489,6 +509,42 @@ module Sentry
|
|
489
509
|
Scope.add_global_event_processor(&block)
|
490
510
|
end
|
491
511
|
|
512
|
+
# Returns the traceparent (sentry-trace) header for distributed tracing.
|
513
|
+
# Can be either from the currently active span or the propagation context.
|
514
|
+
#
|
515
|
+
# @return [String, nil]
|
516
|
+
def get_traceparent
|
517
|
+
return nil unless initialized?
|
518
|
+
get_current_hub.get_traceparent
|
519
|
+
end
|
520
|
+
|
521
|
+
# Returns the baggage header for distributed tracing.
|
522
|
+
# Can be either from the currently active span or the propagation context.
|
523
|
+
#
|
524
|
+
# @return [String, nil]
|
525
|
+
def get_baggage
|
526
|
+
return nil unless initialized?
|
527
|
+
get_current_hub.get_baggage
|
528
|
+
end
|
529
|
+
|
530
|
+
# Returns the a Hash containing sentry-trace and baggage.
|
531
|
+
# Can be either from the currently active span or the propagation context.
|
532
|
+
#
|
533
|
+
# @return [Hash, nil]
|
534
|
+
def get_trace_propagation_headers
|
535
|
+
return nil unless initialized?
|
536
|
+
get_current_hub.get_trace_propagation_headers
|
537
|
+
end
|
538
|
+
|
539
|
+
# Continue an incoming trace from a rack env like hash.
|
540
|
+
#
|
541
|
+
# @param env [Hash]
|
542
|
+
# @return [Transaction, nil]
|
543
|
+
def continue_trace(env, **options)
|
544
|
+
return nil unless initialized?
|
545
|
+
get_current_hub.continue_trace(env, **options)
|
546
|
+
end
|
547
|
+
|
492
548
|
##### Helpers #####
|
493
549
|
|
494
550
|
# @!visibility private
|
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.14.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: 2023-
|
11
|
+
date: 2023-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -56,10 +56,14 @@ files:
|
|
56
56
|
- lib/sentry/breadcrumb.rb
|
57
57
|
- lib/sentry/breadcrumb/sentry_logger.rb
|
58
58
|
- lib/sentry/breadcrumb_buffer.rb
|
59
|
+
- lib/sentry/check_in_event.rb
|
59
60
|
- lib/sentry/client.rb
|
60
61
|
- lib/sentry/configuration.rb
|
61
62
|
- lib/sentry/core_ext/object/deep_dup.rb
|
62
63
|
- lib/sentry/core_ext/object/duplicable.rb
|
64
|
+
- lib/sentry/cron/monitor_check_ins.rb
|
65
|
+
- lib/sentry/cron/monitor_config.rb
|
66
|
+
- lib/sentry/cron/monitor_schedule.rb
|
63
67
|
- lib/sentry/dsn.rb
|
64
68
|
- lib/sentry/envelope.rb
|
65
69
|
- lib/sentry/error_event.rb
|
@@ -78,6 +82,7 @@ files:
|
|
78
82
|
- lib/sentry/logger.rb
|
79
83
|
- lib/sentry/net/http.rb
|
80
84
|
- lib/sentry/profiler.rb
|
85
|
+
- lib/sentry/propagation_context.rb
|
81
86
|
- lib/sentry/puma.rb
|
82
87
|
- lib/sentry/rack.rb
|
83
88
|
- lib/sentry/rack/capture_exceptions.rb
|