sentry-ruby-core 5.27.0 → 5.28.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/lib/sentry/client.rb +3 -2
- data/lib/sentry/configuration.rb +28 -6
- data/lib/sentry/graphql.rb +1 -1
- data/lib/sentry/log_event.rb +17 -4
- data/lib/sentry/metrics/configuration.rb +12 -2
- data/lib/sentry/metrics.rb +12 -0
- data/lib/sentry/std_lib_logger.rb +6 -1
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 348b637110ce05f5a9cab224f11ec3e450163b1701eacc74500a306d8aece567
|
4
|
+
data.tar.gz: 97d7489043a301a9fdfed0d9ca31d38156c5082a0a2e43e83592d86e9eba939d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 406ca22f14011016d5a0082c32a434a7795c143dfdf272c281d966d204646d90188f39a57ca55c142ec63c032ed69f60c5ca3e068e1489dc647d3116f56d4d8f
|
7
|
+
data.tar.gz: cbea0779676929f05597e84da1e4cd7cc25fa0a6d383c8d08e6e26112e9bbe90403d14fdebaa8164a18d5db894ec286d22e5611da217a7bd5efb9279119ace33
|
data/lib/sentry/client.rb
CHANGED
@@ -195,9 +195,10 @@ module Sentry
|
|
195
195
|
def event_from_log(message, level:, **options)
|
196
196
|
return unless configuration.sending_allowed?
|
197
197
|
|
198
|
-
attributes = options.reject { |k, _| k == :level || k == :severity }
|
198
|
+
attributes = options.reject { |k, _| k == :level || k == :severity || k == :origin }
|
199
|
+
origin = options[:origin]
|
199
200
|
|
200
|
-
LogEvent.new(level: level, body: message, attributes: attributes)
|
201
|
+
LogEvent.new(level: level, body: message, attributes: attributes, origin: origin)
|
201
202
|
end
|
202
203
|
|
203
204
|
# Initializes an Event object with the given Transaction object.
|
data/lib/sentry/configuration.rb
CHANGED
@@ -400,7 +400,23 @@ module Sentry
|
|
400
400
|
|
401
401
|
# allow extensions to add their hooks to the Configuration class
|
402
402
|
def add_post_initialization_callback(&block)
|
403
|
-
|
403
|
+
callbacks[:initialize][:after] << block
|
404
|
+
end
|
405
|
+
|
406
|
+
def before(event, &block)
|
407
|
+
callbacks[event.to_sym][:before] << block
|
408
|
+
end
|
409
|
+
|
410
|
+
def after(event, &block)
|
411
|
+
callbacks[event.to_sym][:after] << block
|
412
|
+
end
|
413
|
+
|
414
|
+
# @!visibility private
|
415
|
+
def callbacks
|
416
|
+
@callbacks ||= {
|
417
|
+
initialize: { before: [], after: [] },
|
418
|
+
configured: { before: [], after: [] }
|
419
|
+
}
|
404
420
|
end
|
405
421
|
|
406
422
|
def validations
|
@@ -444,6 +460,8 @@ module Sentry
|
|
444
460
|
validate :profiles_sample_rate, optional: true, type: :numeric
|
445
461
|
|
446
462
|
def initialize
|
463
|
+
run_callbacks(:before, :initialize)
|
464
|
+
|
447
465
|
self.app_dirs_pattern = APP_DIRS_PATTERN
|
448
466
|
self.debug = Sentry::Utils::EnvHelper.env_to_bool(ENV["SENTRY_DEBUG"])
|
449
467
|
self.background_worker_threads = (processor_count / 2.0).ceil
|
@@ -494,13 +512,17 @@ module Sentry
|
|
494
512
|
|
495
513
|
@transport = Transport::Configuration.new
|
496
514
|
@cron = Cron::Configuration.new
|
497
|
-
@metrics = Metrics::Configuration.new
|
515
|
+
@metrics = Metrics::Configuration.new(self.sdk_logger)
|
498
516
|
@structured_logging = StructuredLoggingConfiguration.new
|
499
517
|
@gem_specs = Hash[Gem::Specification.map { |spec| [spec.name, spec.version.to_s] }] if Gem::Specification.respond_to?(:map)
|
500
518
|
|
501
|
-
run_post_initialization_callbacks
|
502
|
-
|
503
519
|
self.max_log_events = LogEventBuffer::DEFAULT_MAX_EVENTS
|
520
|
+
|
521
|
+
run_callbacks(:after, :initialize)
|
522
|
+
|
523
|
+
yield(self) if block_given?
|
524
|
+
|
525
|
+
run_callbacks(:after, :configured)
|
504
526
|
end
|
505
527
|
|
506
528
|
def validate
|
@@ -784,8 +806,8 @@ module Sentry
|
|
784
806
|
File.directory?("/etc/heroku") && !ENV["CI"]
|
785
807
|
end
|
786
808
|
|
787
|
-
def
|
788
|
-
self.class.
|
809
|
+
def run_callbacks(hook, event)
|
810
|
+
self.class.callbacks[event][hook].each do |hook|
|
789
811
|
instance_eval(&hook)
|
790
812
|
end
|
791
813
|
end
|
data/lib/sentry/graphql.rb
CHANGED
@@ -4,6 +4,6 @@ Sentry.register_patch(:graphql) do |config|
|
|
4
4
|
if defined?(::GraphQL::Schema) && defined?(::GraphQL::Tracing::SentryTrace) && ::GraphQL::Schema.respond_to?(:trace_with)
|
5
5
|
::GraphQL::Schema.trace_with(::GraphQL::Tracing::SentryTrace, set_transaction_name: true)
|
6
6
|
else
|
7
|
-
config.
|
7
|
+
config.sdk_logger.warn(Sentry::LOGGER_PROGNAME) { "You tried to enable the GraphQL integration but no GraphQL gem was detected. Make sure you have the `graphql` gem (>= 2.2.6) in your Gemfile." }
|
8
8
|
end
|
9
9
|
end
|
data/lib/sentry/log_event.rb
CHANGED
@@ -29,9 +29,12 @@ module Sentry
|
|
29
29
|
"sentry.address" => :server_name,
|
30
30
|
"sentry.sdk.name" => :sdk_name,
|
31
31
|
"sentry.sdk.version" => :sdk_version,
|
32
|
-
"sentry.message.template" => :template
|
32
|
+
"sentry.message.template" => :template,
|
33
|
+
"sentry.origin" => :origin
|
33
34
|
}
|
34
35
|
|
36
|
+
PARAMETER_PREFIX = "sentry.message.parameter"
|
37
|
+
|
35
38
|
USER_ATTRIBUTES = {
|
36
39
|
"user.id" => :user_id,
|
37
40
|
"user.name" => :user_username,
|
@@ -40,7 +43,7 @@ module Sentry
|
|
40
43
|
|
41
44
|
LEVELS = %i[trace debug info warn error fatal].freeze
|
42
45
|
|
43
|
-
attr_accessor :level, :body, :template, :attributes, :user
|
46
|
+
attr_accessor :level, :body, :template, :attributes, :user, :origin
|
44
47
|
|
45
48
|
attr_reader :configuration, *(SERIALIZEABLE_ATTRIBUTES - %i[level body attributes])
|
46
49
|
|
@@ -51,6 +54,7 @@ module Sentry
|
|
51
54
|
parent_span_id
|
52
55
|
sdk_name
|
53
56
|
sdk_version
|
57
|
+
template
|
54
58
|
timestamp
|
55
59
|
trace_id
|
56
60
|
user_id
|
@@ -79,6 +83,7 @@ module Sentry
|
|
79
83
|
@template = @body if is_template?
|
80
84
|
@attributes = options[:attributes] || DEFAULT_ATTRIBUTES
|
81
85
|
@user = options[:user] || {}
|
86
|
+
@origin = options[:origin]
|
82
87
|
@contexts = {}
|
83
88
|
end
|
84
89
|
|
@@ -146,6 +151,10 @@ module Sentry
|
|
146
151
|
user[:email]
|
147
152
|
end
|
148
153
|
|
154
|
+
def serialize_template
|
155
|
+
template if has_parameters?
|
156
|
+
end
|
157
|
+
|
149
158
|
def serialize_attributes
|
150
159
|
hash = {}
|
151
160
|
|
@@ -185,11 +194,11 @@ module Sentry
|
|
185
194
|
|
186
195
|
if parameters.is_a?(Hash)
|
187
196
|
parameters.each do |key, value|
|
188
|
-
attributes["
|
197
|
+
attributes["#{PARAMETER_PREFIX}.#{key}"] = value
|
189
198
|
end
|
190
199
|
else
|
191
200
|
parameters.each_with_index do |param, index|
|
192
|
-
attributes["
|
201
|
+
attributes["#{PARAMETER_PREFIX}.#{index}"] = param
|
193
202
|
end
|
194
203
|
end
|
195
204
|
end
|
@@ -202,5 +211,9 @@ module Sentry
|
|
202
211
|
def is_template?
|
203
212
|
body.include?("%s") || TOKEN_REGEXP.match?(body)
|
204
213
|
end
|
214
|
+
|
215
|
+
def has_parameters?
|
216
|
+
attributes.keys.any? { |key| key.start_with?(PARAMETER_PREFIX) }
|
217
|
+
end
|
205
218
|
end
|
206
219
|
end
|
@@ -4,12 +4,13 @@ module Sentry
|
|
4
4
|
module Metrics
|
5
5
|
class Configuration
|
6
6
|
include ArgumentCheckingHelper
|
7
|
+
include LoggingHelper
|
7
8
|
|
8
9
|
# Enable metrics usage.
|
9
10
|
# Starts a new {Sentry::Metrics::Aggregator} instance to aggregate metrics
|
10
11
|
# and a thread to aggregate flush every 5 seconds.
|
11
12
|
# @return [Boolean]
|
12
|
-
|
13
|
+
attr_reader :enabled
|
13
14
|
|
14
15
|
# Enable code location reporting.
|
15
16
|
# Will be sent once per day.
|
@@ -32,11 +33,20 @@ module Sentry
|
|
32
33
|
# @return [Proc, nil]
|
33
34
|
attr_reader :before_emit
|
34
35
|
|
35
|
-
def initialize
|
36
|
+
def initialize(sdk_logger)
|
37
|
+
@sdk_logger = sdk_logger
|
36
38
|
@enabled = false
|
37
39
|
@enable_code_locations = true
|
38
40
|
end
|
39
41
|
|
42
|
+
def enabled=(value)
|
43
|
+
log_warn <<~MSG
|
44
|
+
`config.metrics` is now deprecated and will be removed in the next major.
|
45
|
+
MSG
|
46
|
+
|
47
|
+
@enabled = value
|
48
|
+
end
|
49
|
+
|
40
50
|
def before_emit=(value)
|
41
51
|
check_callable!("metrics.before_emit", value)
|
42
52
|
|
data/lib/sentry/metrics.rb
CHANGED
@@ -19,22 +19,28 @@ module Sentry
|
|
19
19
|
|
20
20
|
class << self
|
21
21
|
def increment(key, value = 1.0, unit: "none", tags: {}, timestamp: nil)
|
22
|
+
log_deprecation
|
22
23
|
Sentry.metrics_aggregator&.add(:c, key, value, unit: unit, tags: tags, timestamp: timestamp)
|
23
24
|
end
|
24
25
|
|
25
26
|
def distribution(key, value, unit: "none", tags: {}, timestamp: nil)
|
27
|
+
log_deprecation
|
26
28
|
Sentry.metrics_aggregator&.add(:d, key, value, unit: unit, tags: tags, timestamp: timestamp)
|
27
29
|
end
|
28
30
|
|
29
31
|
def set(key, value, unit: "none", tags: {}, timestamp: nil)
|
32
|
+
log_deprecation
|
30
33
|
Sentry.metrics_aggregator&.add(:s, key, value, unit: unit, tags: tags, timestamp: timestamp)
|
31
34
|
end
|
32
35
|
|
33
36
|
def gauge(key, value, unit: "none", tags: {}, timestamp: nil)
|
37
|
+
log_deprecation
|
34
38
|
Sentry.metrics_aggregator&.add(:g, key, value, unit: unit, tags: tags, timestamp: timestamp)
|
35
39
|
end
|
36
40
|
|
37
41
|
def timing(key, unit: "second", tags: {}, timestamp: nil, &block)
|
42
|
+
log_deprecation
|
43
|
+
|
38
44
|
return unless block_given?
|
39
45
|
return yield unless DURATION_UNITS.include?(unit)
|
40
46
|
|
@@ -51,6 +57,12 @@ module Sentry
|
|
51
57
|
Sentry.metrics_aggregator&.add(:d, key, value, unit: unit, tags: tags, timestamp: timestamp)
|
52
58
|
result
|
53
59
|
end
|
60
|
+
|
61
|
+
def log_deprecation
|
62
|
+
Sentry.sdk_logger.warn(LOGGER_PROGNAME) do
|
63
|
+
"`Sentry::Metrics` is now deprecated and will be removed in the next major."
|
64
|
+
end
|
65
|
+
end
|
54
66
|
end
|
55
67
|
end
|
56
68
|
end
|
@@ -12,11 +12,16 @@ module Sentry
|
|
12
12
|
4 => :fatal
|
13
13
|
}.freeze
|
14
14
|
|
15
|
+
ORIGIN = "auto.logger.ruby.std_logger"
|
16
|
+
|
15
17
|
def add(severity, message = nil, progname = nil, &block)
|
16
18
|
result = super
|
17
19
|
|
18
20
|
return unless Sentry.initialized? && Sentry.get_current_hub
|
19
21
|
|
22
|
+
# Only process logs that meet or exceed the logger's level
|
23
|
+
return result if severity < level
|
24
|
+
|
20
25
|
# exclude sentry SDK logs -- to prevent recursive log action,
|
21
26
|
# do not process internal logs again
|
22
27
|
if message.nil? && progname != Sentry::Logger::PROGNAME
|
@@ -32,7 +37,7 @@ module Sentry
|
|
32
37
|
message = message.to_s.strip
|
33
38
|
|
34
39
|
if !message.nil? && message != Sentry::Logger::PROGNAME && method = SEVERITY_MAP[severity]
|
35
|
-
Sentry.logger.send(method, message)
|
40
|
+
Sentry.logger.send(method, message, origin: ORIGIN)
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
data/lib/sentry/version.rb
CHANGED
data/lib/sentry-ruby.rb
CHANGED
@@ -239,8 +239,7 @@ module Sentry
|
|
239
239
|
# @yieldparam config [Configuration]
|
240
240
|
# @return [void]
|
241
241
|
def init(&block)
|
242
|
-
config = Configuration.new
|
243
|
-
yield(config) if block_given?
|
242
|
+
config = Configuration.new(&block)
|
244
243
|
|
245
244
|
config.detect_release
|
246
245
|
apply_patches(config)
|
@@ -500,6 +499,7 @@ module Sentry
|
|
500
499
|
# @param [Hash] options Extra log event options
|
501
500
|
# @option options [Symbol] level The log level (:trace, :debug, :info, :warn, :error, :fatal)
|
502
501
|
# @option options [Integer] severity The severity number according to the Sentry Logs Protocol
|
502
|
+
# @option options [String] origin The origin of the log event (e.g., "auto.db.rails", "manual")
|
503
503
|
# @option options [Hash] Additional attributes to include with the log
|
504
504
|
#
|
505
505
|
# @example Direct usage (prefer using Sentry.logger instead)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-ruby-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - '='
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 5.
|
18
|
+
version: 5.28.0
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - '='
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 5.
|
25
|
+
version: 5.28.0
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: concurrent-ruby
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|