sentry-ruby 5.27.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e22f6e466bbb07f16fcec111522500b84246820d9cdfbbbe055fab491de4a5b1
4
- data.tar.gz: fae1030444c280ce570da19bad7e922fa734838bd7b5e16620bba19d21137cd1
3
+ metadata.gz: 0a048bcf517a994eb2577cc8f9630e7771f0dbe9a80cff9a93e1d4d68186db49
4
+ data.tar.gz: 97d7489043a301a9fdfed0d9ca31d38156c5082a0a2e43e83592d86e9eba939d
5
5
  SHA512:
6
- metadata.gz: 9872cecd24210d7085c9a7f3e8b58daba0d630f7a4c37ba8b23db062b077ad6c388544e6bde57cf2383ab7e81839501272a52fc0499c0320acd085dd1f4010a0
7
- data.tar.gz: 99e0504418c5b0ecddc3a84558935076c50f948937a5545c91451dec1bfa885a078f5141ad38290d8bab082a19ed355010bf945ca29faa25ca9f086a6777ba96
6
+ metadata.gz: 17466b57a83b0292b367b43dcf7c22128ae93822ab7481f3afb3459c52842c917c57d3b2274a3e377fcfd089ab10efa1e12bdd7401a991018387fb026e5fe014
7
+ data.tar.gz: cbea0779676929f05597e84da1e4cd7cc25fa0a6d383c8d08e6e26112e9bbe90403d14fdebaa8164a18d5db894ec286d22e5611da217a7bd5efb9279119ace33
@@ -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
- post_initialization_callbacks << block
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 run_post_initialization_callbacks
788
- self.class.post_initialization_callbacks.each do |hook|
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
@@ -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.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." }
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
@@ -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
- attr_accessor :enabled
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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
- VERSION = "5.27.1"
4
+ VERSION = "5.28.0"
5
5
  end
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)
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: 5.27.1
4
+ version: 5.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
@@ -158,15 +158,15 @@ files:
158
158
  - lib/sentry/version.rb
159
159
  - sentry-ruby-core.gemspec
160
160
  - sentry-ruby.gemspec
161
- homepage: https://github.com/getsentry/sentry-ruby/tree/5.27.1/sentry-ruby
161
+ homepage: https://github.com/getsentry/sentry-ruby/tree/5.28.0/sentry-ruby
162
162
  licenses:
163
163
  - MIT
164
164
  metadata:
165
- homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.27.1/sentry-ruby
166
- source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.27.1/sentry-ruby
167
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.27.1/CHANGELOG.md
165
+ homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.28.0/sentry-ruby
166
+ source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.28.0/sentry-ruby
167
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.28.0/CHANGELOG.md
168
168
  bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
169
- documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/5.27.1
169
+ documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/5.28.0
170
170
  rdoc_options: []
171
171
  require_paths:
172
172
  - lib