sentry-ruby-core 4.7.3 → 4.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -0
  3. data/Gemfile +6 -2
  4. data/README.md +7 -7
  5. data/bin/console +5 -1
  6. data/lib/sentry/background_worker.rb +30 -2
  7. data/lib/sentry/backtrace.rb +1 -0
  8. data/lib/sentry/breadcrumb/sentry_logger.rb +2 -0
  9. data/lib/sentry/breadcrumb.rb +2 -0
  10. data/lib/sentry/breadcrumb_buffer.rb +2 -0
  11. data/lib/sentry/client.rb +13 -1
  12. data/lib/sentry/configuration.rb +136 -112
  13. data/lib/sentry/core_ext/object/deep_dup.rb +2 -0
  14. data/lib/sentry/core_ext/object/duplicable.rb +1 -0
  15. data/lib/sentry/dsn.rb +2 -0
  16. data/lib/sentry/envelope.rb +26 -0
  17. data/lib/sentry/event.rb +5 -0
  18. data/lib/sentry/exceptions.rb +2 -0
  19. data/lib/sentry/hub.rb +7 -0
  20. data/lib/sentry/integrable.rb +2 -0
  21. data/lib/sentry/interface.rb +2 -0
  22. data/lib/sentry/interfaces/exception.rb +2 -0
  23. data/lib/sentry/interfaces/single_exception.rb +31 -0
  24. data/lib/sentry/interfaces/stacktrace.rb +10 -0
  25. data/lib/sentry/interfaces/stacktrace_builder.rb +2 -0
  26. data/lib/sentry/interfaces/threads.rb +2 -0
  27. data/lib/sentry/linecache.rb +3 -0
  28. data/lib/sentry/net/http.rb +3 -0
  29. data/lib/sentry/rack/capture_exceptions.rb +2 -0
  30. data/lib/sentry/rack.rb +2 -0
  31. data/lib/sentry/rake.rb +16 -6
  32. data/lib/sentry/release_detector.rb +39 -0
  33. data/lib/sentry/scope.rb +8 -4
  34. data/lib/sentry/span.rb +1 -0
  35. data/lib/sentry/transaction.rb +6 -1
  36. data/lib/sentry/transport/configuration.rb +2 -0
  37. data/lib/sentry/transport/dummy_transport.rb +2 -0
  38. data/lib/sentry/transport/http_transport.rb +6 -4
  39. data/lib/sentry/transport.rb +77 -19
  40. data/lib/sentry/utils/argument_checking_helper.rb +2 -0
  41. data/lib/sentry/utils/custom_inspection.rb +14 -0
  42. data/lib/sentry/utils/exception_cause_chain.rb +10 -10
  43. data/lib/sentry/utils/logging_helper.rb +2 -0
  44. data/lib/sentry/utils/real_ip.rb +2 -0
  45. data/lib/sentry/utils/request_id.rb +2 -0
  46. data/lib/sentry/version.rb +3 -1
  47. data/lib/sentry-ruby.rb +102 -28
  48. data/sentry-ruby.gemspec +1 -1
  49. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9ceb36eb4db5018e7b309949fa8ae468c07f0687c0227fd9f8b20e68e216776
4
- data.tar.gz: e214379b67e80cb89c7f70a36739bd2f067af6fa9227acf125349a2aef2c8ea4
3
+ metadata.gz: 8b41956862e17f8b60319bac7a72b253889aad50b0518b4dd119bcc5da246c2c
4
+ data.tar.gz: 8e37db5f09d89bf1382e89744ae2a4c3a5112d4d0a5aa3f105b754974cb5d1a7
5
5
  SHA512:
6
- metadata.gz: 2bfdb4d169ba1d9c896273401df8891b51f5fc016609154a1ec02bf064bf956bc4ce69ab85cafc4c82001ccaf475d86bc18d4064f1cdd8563ae03761a0245604
7
- data.tar.gz: 53ce1e1f6d4957a1c3ad327cc7e51d154da1da32c863ad21fd0ce3aca09273fa794c08b39ee7adfafd96e7afa30555b87a2f2013b345906a0218001d177d3bec
6
+ metadata.gz: 9603b5d16ee470d52fa2052a7f9156c7a2e709d906e7299e661648bec6ab56b1c076de19c8b9ea37a97dafc0f21f59dc12898e2b1bde02d14de4e725d5aa1120
7
+ data.tar.gz: 2c511329f550a6d9c495b55d9e40731d55e953ffc9632dcdcbfcc88266edc95287fc7d912161b853421ec0e281e9dc6dc1574d4523939b92d1c08cca569e7185
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --exclude lib/sentry/utils/
2
+ --exclude lib/sentry/core_ext
data/Gemfile CHANGED
@@ -10,13 +10,17 @@ gem "rspec", "~> 3.0"
10
10
  gem "rspec-retry"
11
11
  gem "webmock"
12
12
  gem "timecop"
13
- gem "codecov", "0.2.12"
13
+ gem 'simplecov'
14
+ gem "simplecov-cobertura", "~> 1.4"
15
+ gem "rexml"
14
16
 
15
17
  gem "object_tracer"
16
- gem "debug", github: "ruby/debug" if RUBY_VERSION.to_f >= 2.6
18
+ gem "debug", github: "ruby/debug", platform: :ruby if RUBY_VERSION.to_f >= 2.6
17
19
  gem "pry"
18
20
 
19
21
  gem "benchmark-ips"
20
22
  gem "benchmark_driver"
21
23
  gem "benchmark-ipsa"
22
24
  gem "benchmark-memory"
25
+
26
+ gem "yard", "~> 0.9.27"
data/README.md CHANGED
@@ -10,13 +10,13 @@ _Bad software is everywhere, and we're tired of it. Sentry is on a mission to he
10
10
  Sentry SDK for Ruby
11
11
  ===========
12
12
 
13
- | current version | build | coverage | downloads | semver stability |
14
- | --- | ----- | -------- | --------- | ---------------- |
15
- | [![Gem Version](https://img.shields.io/gem/v/sentry-ruby?label=sentry-ruby)](https://rubygems.org/gems/sentry-ruby) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-ruby%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_ruby_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-ruby.svg)](https://rubygems.org/gems/sentry-ruby/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-ruby&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-ruby&package-manager=bundler&version-scheme=semver) |
16
- | [![Gem Version](https://img.shields.io/gem/v/sentry-rails?label=sentry-rails)](https://rubygems.org/gems/sentry-rails) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-rails%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_rails_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-rails.svg)](https://rubygems.org/gems/sentry-rails/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-rails&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-rails&package-manager=bundler&version-scheme=semver) |
17
- | [![Gem Version](https://img.shields.io/gem/v/sentry-sidekiq?label=sentry-sidekiq)](https://rubygems.org/gems/sentry-sidekiq) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-sidekiq%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_sidekiq_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-sidekiq.svg)](https://rubygems.org/gems/sentry-sidekiq/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-sidekiq&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-sidekiq&package-manager=bundler&version-scheme=semver) |
18
- | [![Gem Version](https://img.shields.io/gem/v/sentry-delayed_job?label=sentry-delayed_job)](https://rubygems.org/gems/sentry-delayed_job) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-delayed_job%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_delayed_job_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-delayed_job.svg)](https://rubygems.org/gems/sentry-delayed_job/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-delayed_job&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-delayed_job&package-manager=bundler&version-scheme=semver) |
19
- | [![Gem Version](https://img.shields.io/gem/v/sentry-resque?label=sentry-resque)](https://rubygems.org/gems/sentry-resque) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-resque%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_resque_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-resque.svg)](https://rubygems.org/gems/sentry-resque/) | [![SemVer stability](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-resque&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-resque&package-manager=bundler&version-scheme=semver) |
13
+ | current version | build | coverage | downloads |
14
+ | --- | ----- | -------- | --------- |
15
+ | [![Gem Version](https://img.shields.io/gem/v/sentry-ruby?label=sentry-ruby)](https://rubygems.org/gems/sentry-ruby) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-ruby%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_ruby_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-ruby.svg)](https://rubygems.org/gems/sentry-ruby/) |
16
+ | [![Gem Version](https://img.shields.io/gem/v/sentry-rails?label=sentry-rails)](https://rubygems.org/gems/sentry-rails) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-rails%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_rails_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-rails.svg)](https://rubygems.org/gems/sentry-rails/) |
17
+ | [![Gem Version](https://img.shields.io/gem/v/sentry-sidekiq?label=sentry-sidekiq)](https://rubygems.org/gems/sentry-sidekiq) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-sidekiq%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_sidekiq_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-sidekiq.svg)](https://rubygems.org/gems/sentry-sidekiq/) |
18
+ | [![Gem Version](https://img.shields.io/gem/v/sentry-delayed_job?label=sentry-delayed_job)](https://rubygems.org/gems/sentry-delayed_job) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-delayed_job%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_delayed_job_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-delayed_job.svg)](https://rubygems.org/gems/sentry-delayed_job/) |
19
+ | [![Gem Version](https://img.shields.io/gem/v/sentry-resque?label=sentry-resque)](https://rubygems.org/gems/sentry-resque) | [![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-resque%20Test/badge.svg)](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_resque_test.yml) | [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master) | [![Downloads](https://img.shields.io/gem/dt/sentry-resque.svg)](https://rubygems.org/gems/sentry-resque/) |
20
20
 
21
21
 
22
22
 
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "sentry/ruby"
4
+ require "sentry-ruby"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,9 @@ require "sentry/ruby"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
+ # Sentry.init do |config|
14
+ # config.dsn = 'https://2fb45f003d054a7ea47feb45898f7649@o447951.ingest.sentry.io/5434472'
15
+ # end
16
+
13
17
  require "irb"
14
18
  IRB.start(__FILE__)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "concurrent/executor/thread_pool_executor"
2
4
  require "concurrent/executor/immediate_executor"
3
5
  require "concurrent/configuration"
@@ -7,11 +9,15 @@ module Sentry
7
9
  include LoggingHelper
8
10
 
9
11
  attr_reader :max_queue, :number_of_threads, :logger
12
+ attr_accessor :shutdown_timeout
10
13
 
11
14
  def initialize(configuration)
12
15
  @max_queue = 30
16
+ @shutdown_timeout = 1
13
17
  @number_of_threads = configuration.background_worker_threads
14
18
  @logger = configuration.logger
19
+ @debug = configuration.debug
20
+ @shutdown_callback = nil
15
21
 
16
22
  @executor =
17
23
  if configuration.async
@@ -23,19 +29,41 @@ module Sentry
23
29
  else
24
30
  log_debug("initialized a background worker with #{@number_of_threads} threads")
25
31
 
26
- Concurrent::ThreadPoolExecutor.new(
32
+ executor = Concurrent::ThreadPoolExecutor.new(
27
33
  min_threads: 0,
28
34
  max_threads: @number_of_threads,
29
35
  max_queue: @max_queue,
30
36
  fallback_policy: :discard
31
37
  )
38
+
39
+ @shutdown_callback = proc do
40
+ executor.shutdown
41
+ executor.wait_for_termination(@shutdown_timeout)
42
+ end
43
+
44
+ executor
32
45
  end
33
46
  end
34
47
 
48
+ # if you want to monkey-patch this method, please override `_perform` instead
35
49
  def perform(&block)
36
50
  @executor.post do
37
- block.call
51
+ begin
52
+ _perform(&block)
53
+ rescue Exception => e
54
+ log_error("exception happened in background worker", e, debug: @debug)
55
+ end
38
56
  end
39
57
  end
58
+
59
+ def shutdown
60
+ @shutdown_callback&.call
61
+ end
62
+
63
+ private
64
+
65
+ def _perform(&block)
66
+ block.call
67
+ end
40
68
  end
41
69
  end
@@ -4,6 +4,7 @@
4
4
 
5
5
  module Sentry
6
6
  # Front end to parsing the backtrace for each notice
7
+ # @api private
7
8
  class Backtrace
8
9
  # Handles backtrace parsing line by line
9
10
  class Line
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
 
3
5
  module Sentry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sentry
2
4
  class Breadcrumb
3
5
  DATA_SERIALIZATION_ERROR_MESSAGE = "[data were removed due to serialization issues]"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sentry/breadcrumb"
2
4
 
3
5
  module Sentry
data/lib/sentry/client.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sentry/transport"
2
4
 
3
5
  module Sentry
@@ -26,17 +28,25 @@ module Sentry
26
28
  def capture_event(event, scope, hint = {})
27
29
  return unless configuration.sending_allowed?
28
30
 
31
+ unless event.is_a?(TransactionEvent) || configuration.sample_allowed?
32
+ transport.record_lost_event(:sample_rate, 'event')
33
+ return
34
+ end
35
+
36
+ event_type = event.is_a?(Event) ? event.type : event["type"]
29
37
  event = scope.apply_to_event(event, hint)
30
38
 
31
39
  if event.nil?
32
40
  log_info("Discarded event because one of the event processors returned nil")
41
+ transport.record_lost_event(:event_processor, event_type)
33
42
  return
34
43
  end
35
44
 
36
45
  if async_block = configuration.async
37
46
  dispatch_async_event(async_block, event, hint)
38
47
  elsif configuration.background_worker_threads != 0 && hint.fetch(:background, true)
39
- dispatch_background_event(event, hint)
48
+ queued = dispatch_background_event(event, hint)
49
+ transport.record_lost_event(:queue_overflow, event_type) unless queued
40
50
  else
41
51
  send_event(event, hint)
42
52
  end
@@ -84,6 +94,7 @@ module Sentry
84
94
 
85
95
  if event.nil?
86
96
  log_info("Discarded event because before_send returned nil")
97
+ transport.record_lost_event(:before_send, 'event')
87
98
  return
88
99
  end
89
100
  end
@@ -97,6 +108,7 @@ module Sentry
97
108
 
98
109
  event_info = Event.get_log_message(event.to_hash)
99
110
  log_info("Unreported #{loggable_event_type}: #{event_info}")
111
+ transport.record_lost_event(:network_error, event_type)
100
112
  raise
101
113
  end
102
114