sentry-sidekiq 4.1.3 → 4.4.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/.craft.yml +3 -2
 - data/.rspec +0 -1
 - data/CHANGELOG.md +36 -0
 - data/Gemfile +4 -1
 - data/Makefile +4 -0
 - data/example/error_worker.rb +2 -0
 - data/lib/sentry-sidekiq.rb +10 -1
 - data/lib/sentry/sidekiq/context_filter.rb +40 -10
 - data/lib/sentry/sidekiq/error_handler.rb +5 -22
 - data/lib/sentry/sidekiq/sentry_context_middleware.rb +23 -3
 - data/lib/sentry/sidekiq/version.rb +1 -1
 - data/sentry-sidekiq.gemspec +1 -1
 - metadata +5 -6
 - data/lib/sentry/sidekiq/cleanup_middleware.rb +0 -21
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: ca9211c7be3a1908bb922b5ce58c349224daa127f370f8fd99bec28feb190756
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 482d296fb5620c83a781037bb27407920312357587c6d9caf6e0ba9056fb01d7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: be30ec169a1e7a74a5bfae1504cc8f76c970cdb8baf6d638f14fc8a72fefa166b637c237472b68c334d9e371c8eb15c24d7b46d22e97ecf99271980f8960f982
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: dc8cdab4af7e2e9bbe66e75403b36bf99ce3d65c5a54b53427b2110b3c019cc10cbbd5776f5b4967594835267fd14b38d39f7300d57ec776c779c95b81901ad2
         
     | 
    
        data/.craft.yml
    CHANGED
    
    | 
         @@ -11,9 +11,10 @@ artifactProvider: 
     | 
|
| 
       11 
11 
     | 
    
         
             
              name: github
         
     | 
| 
       12 
12 
     | 
    
         
             
            targets:
         
     | 
| 
       13 
13 
     | 
    
         
             
                - name: gem
         
     | 
| 
       14 
     | 
    
         
            -
                - name: github
         
     | 
| 
       15 
     | 
    
         
            -
                  tagPrefix: sentry-sidekiq-v
         
     | 
| 
       16 
14 
     | 
    
         
             
                - name: registry
         
     | 
| 
       17 
15 
     | 
    
         
             
                  type: sdk
         
     | 
| 
       18 
16 
     | 
    
         
             
                  config:
         
     | 
| 
       19 
17 
     | 
    
         
             
                      canonical: 'gem:sentry-sidekiq'
         
     | 
| 
      
 18 
     | 
    
         
            +
                - name: github
         
     | 
| 
      
 19 
     | 
    
         
            +
                  tagPrefix: sentry-sidekiq-v
         
     | 
| 
      
 20 
     | 
    
         
            +
                  changelog: sentry-sidekiq/CHANGELOG.md
         
     | 
    
        data/.rspec
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,41 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Changelog
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## 4.4.0
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ### Features
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            - Make Sidekiq job context more readable [#1410](https://github.com/getsentry/sentry-ruby/pull/1410) 
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            **Before**
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            <img width="60%" alt="Sidekiq payload in extra" src="https://user-images.githubusercontent.com/5079556/115679342-0ed8d000-a385-11eb-8e1c-372cb1af572e.png">
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            **After**
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            <img width="60%" alt="Sidekiq payload in context" src="https://user-images.githubusercontent.com/5079556/115679353-126c5700-a385-11eb-867c-a9a25d1a7099.png">
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ## 4.3.0
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ### Features
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            - Support performance monitoring on Sidekiq workers [#1311](https://github.com/getsentry/sentry-ruby/pull/1311)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## 4.2.1
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            - Use ::Rails::Railtie for checking Rails definition [#1284](https://github.com/getsentry/sentry-ruby/pull/1284)
         
     | 
| 
      
 26 
     | 
    
         
            +
              - Fixes [#1276](https://github.com/getsentry/sentry-ruby/issues/1276)
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            ## 4.2.0
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            ### Features
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            - Tag queue name and jid on sidekiq events [#1258](https://github.com/getsentry/sentry-ruby/pull/1258)
         
     | 
| 
      
 33 
     | 
    
         
            +
            <img width="1234" alt="sidekiq event tagged with queue name and jid" src="https://user-images.githubusercontent.com/5079556/106389900-d0381700-6420-11eb-90b9-a95b0881b696.png">
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            ### Refactorings
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            - Add sidekiq adapter to sentry-rails' ignored adapters list [#1257](https://github.com/getsentry/sentry-ruby/pull/1257)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       3 
39 
     | 
    
         
             
            ## 4.1.3
         
     | 
| 
       4 
40 
     | 
    
         | 
| 
       5 
41 
     | 
    
         
             
            - Use sentry-ruby-core as the main SDK dependency [#1245](https://github.com/getsentry/sentry-ruby/pull/1245)
         
     | 
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -3,13 +3,16 @@ source "https://rubygems.org" 
     | 
|
| 
       3 
3 
     | 
    
         
             
            # Specify your gem's dependencies in sentry-ruby.gemspec
         
     | 
| 
       4 
4 
     | 
    
         
             
            gemspec
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
            gem "i18n", "~> 1.8.9"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       6 
8 
     | 
    
         
             
            gem "rake", "~> 12.0"
         
     | 
| 
       7 
9 
     | 
    
         
             
            gem "rspec", "~> 3.0"
         
     | 
| 
       8 
10 
     | 
    
         
             
            gem "codecov", "0.2.12"
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
       10 
12 
     | 
    
         
             
            gem "sidekiq"
         
     | 
| 
       11 
     | 
    
         
            -
            gem " 
     | 
| 
      
 13 
     | 
    
         
            +
            gem "rails"
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
15 
     | 
    
         
             
            gem "sentry-ruby", path: "../sentry-ruby"
         
     | 
| 
      
 16 
     | 
    
         
            +
            gem "sentry-rails", path: "../sentry-rails"
         
     | 
| 
       14 
17 
     | 
    
         | 
| 
       15 
18 
     | 
    
         
             
            gem "pry"
         
     | 
    
        data/Makefile
    CHANGED
    
    
    
        data/example/error_worker.rb
    CHANGED
    
    
    
        data/lib/sentry-sidekiq.rb
    CHANGED
    
    | 
         @@ -4,13 +4,22 @@ require "sentry/integrable" 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require "sentry/sidekiq/version"
         
     | 
| 
       5 
5 
     | 
    
         
             
            require "sentry/sidekiq/error_handler"
         
     | 
| 
       6 
6 
     | 
    
         
             
            require "sentry/sidekiq/sentry_context_middleware"
         
     | 
| 
       7 
     | 
    
         
            -
            # require "sentry/sidekiq/configuration"
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
8 
     | 
    
         
             
            module Sentry
         
     | 
| 
       10 
9 
     | 
    
         
             
              module Sidekiq
         
     | 
| 
       11 
10 
     | 
    
         
             
                extend Sentry::Integrable
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
       13 
12 
     | 
    
         
             
                register_integration name: "sidekiq", version: Sentry::Sidekiq::VERSION
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                if defined?(::Rails::Railtie)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  class Railtie < ::Rails::Railtie
         
     | 
| 
      
 16 
     | 
    
         
            +
                    config.after_initialize do
         
     | 
| 
      
 17 
     | 
    
         
            +
                      next unless Sentry.initialized?
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                      Sentry.configuration.rails.skippable_job_adapters << "ActiveJob::QueueAdapters::SidekiqAdapter"
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
       14 
23 
     | 
    
         
             
              end
         
     | 
| 
       15 
24 
     | 
    
         
             
            end
         
     | 
| 
       16 
25 
     | 
    
         | 
| 
         @@ -2,8 +2,12 @@ module Sentry 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Sidekiq
         
     | 
| 
       3 
3 
     | 
    
         
             
                class ContextFilter
         
     | 
| 
       4 
4 
     | 
    
         
             
                  ACTIVEJOB_RESERVED_PREFIX_REGEX = /^_aj_/.freeze
         
     | 
| 
      
 5 
     | 
    
         
            +
                  SIDEKIQ_NAME = "Sidekiq".freeze
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 7 
     | 
    
         
            +
                  attr_reader :context
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  def initialize(context)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @context = context
         
     | 
| 
       7 
11 
     | 
    
         
             
                    @has_global_id = defined?(GlobalID)
         
     | 
| 
       8 
12 
     | 
    
         
             
                  end
         
     | 
| 
       9 
13 
     | 
    
         | 
| 
         @@ -13,23 +17,49 @@ module Sentry 
     | 
|
| 
       13 
17 
     | 
    
         
             
                  # The problem is, if this job in turn gets queued back into ActiveJob with
         
     | 
| 
       14 
18 
     | 
    
         
             
                  # these magic reserved keys, ActiveJob will throw up and error. We want to
         
     | 
| 
       15 
19 
     | 
    
         
             
                  # capture these and mutate the keys so we can sanely report it.
         
     | 
| 
       16 
     | 
    
         
            -
                  def  
     | 
| 
       17 
     | 
    
         
            -
                     
     | 
| 
      
 20 
     | 
    
         
            +
                  def filtered
         
     | 
| 
      
 21 
     | 
    
         
            +
                    filtered_context = filter_context(context)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    if job_entry = filtered_context.delete(:job)
         
     | 
| 
      
 24 
     | 
    
         
            +
                      job_entry.each do |k, v|
         
     | 
| 
      
 25 
     | 
    
         
            +
                        filtered_context[k] = v
         
     | 
| 
      
 26 
     | 
    
         
            +
                      end
         
     | 
| 
      
 27 
     | 
    
         
            +
                    end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                    filtered_context
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def transaction_name
         
     | 
| 
      
 33 
     | 
    
         
            +
                    class_name = (context["wrapped"] || context["class"] ||
         
     | 
| 
      
 34 
     | 
    
         
            +
                                  (context[:job] && (context[:job]["wrapped"] || context[:job]["class"]))
         
     | 
| 
      
 35 
     | 
    
         
            +
                                )
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                    if class_name
         
     | 
| 
      
 38 
     | 
    
         
            +
                      "#{SIDEKIQ_NAME}/#{class_name}"
         
     | 
| 
      
 39 
     | 
    
         
            +
                    elsif context[:event]
         
     | 
| 
      
 40 
     | 
    
         
            +
                      "#{SIDEKIQ_NAME}/#{context[:event]}"
         
     | 
| 
      
 41 
     | 
    
         
            +
                    else
         
     | 
| 
      
 42 
     | 
    
         
            +
                      SIDEKIQ_NAME
         
     | 
| 
      
 43 
     | 
    
         
            +
                    end
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  private
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  def filter_context(hash)
         
     | 
| 
      
 49 
     | 
    
         
            +
                    case hash
         
     | 
| 
       18 
50 
     | 
    
         
             
                    when Array
         
     | 
| 
       19 
     | 
    
         
            -
                       
     | 
| 
      
 51 
     | 
    
         
            +
                      hash.map { |arg| filter_context(arg) }
         
     | 
| 
       20 
52 
     | 
    
         
             
                    when Hash
         
     | 
| 
       21 
     | 
    
         
            -
                      Hash[ 
     | 
| 
      
 53 
     | 
    
         
            +
                      Hash[hash.map { |key, value| filter_context_hash(key, value) }]
         
     | 
| 
       22 
54 
     | 
    
         
             
                    else
         
     | 
| 
       23 
     | 
    
         
            -
                      if has_global_id? &&  
     | 
| 
       24 
     | 
    
         
            -
                         
     | 
| 
      
 55 
     | 
    
         
            +
                      if has_global_id? && hash.is_a?(GlobalID)
         
     | 
| 
      
 56 
     | 
    
         
            +
                        hash.to_s
         
     | 
| 
       25 
57 
     | 
    
         
             
                      else
         
     | 
| 
       26 
     | 
    
         
            -
                         
     | 
| 
      
 58 
     | 
    
         
            +
                        hash
         
     | 
| 
       27 
59 
     | 
    
         
             
                      end
         
     | 
| 
       28 
60 
     | 
    
         
             
                    end
         
     | 
| 
       29 
61 
     | 
    
         
             
                  end
         
     | 
| 
       30 
62 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                  private
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
63 
     | 
    
         
             
                  def filter_context_hash(key, value)
         
     | 
| 
       34 
64 
     | 
    
         
             
                    key = key.to_s.sub(ACTIVEJOB_RESERVED_PREFIX_REGEX, "") if key.match(ACTIVEJOB_RESERVED_PREFIX_REGEX)
         
     | 
| 
       35 
65 
     | 
    
         
             
                    [key, filter_context(value)]
         
     | 
| 
         @@ -3,37 +3,20 @@ require 'sentry/sidekiq/context_filter' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module Sentry
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Sidekiq
         
     | 
| 
       5 
5 
     | 
    
         
             
                class ErrorHandler
         
     | 
| 
       6 
     | 
    
         
            -
                  SIDEKIQ_NAME = "Sidekiq".freeze
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
6 
     | 
    
         
             
                  def call(ex, context)
         
     | 
| 
       9 
7 
     | 
    
         
             
                    return unless Sentry.initialized?
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    context_filter = Sentry::Sidekiq::ContextFilter.new(context)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       11 
11 
     | 
    
         
             
                    scope = Sentry.get_current_scope
         
     | 
| 
       12 
     | 
    
         
            -
                    scope.set_transaction_name( 
     | 
| 
      
 12 
     | 
    
         
            +
                    scope.set_transaction_name(context_filter.transaction_name) unless scope.transaction_name
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                    Sentry::Sidekiq.capture_exception(
         
     | 
| 
       15 
15 
     | 
    
         
             
                      ex,
         
     | 
| 
       16 
     | 
    
         
            -
                       
     | 
| 
      
 16 
     | 
    
         
            +
                      contexts: { sidekiq: context_filter.filtered },
         
     | 
| 
       17 
17 
     | 
    
         
             
                      hint: { background: false }
         
     | 
| 
       18 
18 
     | 
    
         
             
                    )
         
     | 
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                  private
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                  # this will change in the future:
         
     | 
| 
       24 
     | 
    
         
            -
                  # https://github.com/mperham/sidekiq/pull/3161
         
     | 
| 
       25 
     | 
    
         
            -
                  def transaction_from_context(context)
         
     | 
| 
       26 
     | 
    
         
            -
                    classname = (context["wrapped"] || context["class"] ||
         
     | 
| 
       27 
     | 
    
         
            -
                                  (context[:job] && (context[:job]["wrapped"] || context[:job]["class"]))
         
     | 
| 
       28 
     | 
    
         
            -
                                )
         
     | 
| 
       29 
     | 
    
         
            -
                    if classname
         
     | 
| 
       30 
     | 
    
         
            -
                      "#{SIDEKIQ_NAME}/#{classname}"
         
     | 
| 
       31 
     | 
    
         
            -
                    elsif context[:event]
         
     | 
| 
       32 
     | 
    
         
            -
                      "#{SIDEKIQ_NAME}/#{context[:event]}"
         
     | 
| 
       33 
     | 
    
         
            -
                    else
         
     | 
| 
       34 
     | 
    
         
            -
                      SIDEKIQ_NAME
         
     | 
| 
       35 
     | 
    
         
            -
                    end
         
     | 
| 
       36 
     | 
    
         
            -
                  end
         
     | 
| 
       37 
20 
     | 
    
         
             
                end
         
     | 
| 
       38 
21 
     | 
    
         
             
              end
         
     | 
| 
       39 
22 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,20 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'sentry/sidekiq/context_filter'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Sentry
         
     | 
| 
       2 
4 
     | 
    
         
             
              module Sidekiq
         
     | 
| 
       3 
5 
     | 
    
         
             
                class SentryContextMiddleware
         
     | 
| 
       4 
6 
     | 
    
         
             
                  def call(_worker, job, queue)
         
     | 
| 
       5 
7 
     | 
    
         
             
                    return yield unless Sentry.initialized?
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
                    context_filter = Sentry::Sidekiq::ContextFilter.new(job)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       7 
11 
     | 
    
         
             
                    Sentry.clone_hub_to_current_thread
         
     | 
| 
       8 
12 
     | 
    
         
             
                    scope = Sentry.get_current_scope
         
     | 
| 
       9 
     | 
    
         
            -
                    scope. 
     | 
| 
       10 
     | 
    
         
            -
                    scope. 
     | 
| 
      
 13 
     | 
    
         
            +
                    scope.set_tags(queue: queue, jid: job["jid"])
         
     | 
| 
      
 14 
     | 
    
         
            +
                    scope.set_contexts(sidekiq: job.merge("queue" => queue))
         
     | 
| 
      
 15 
     | 
    
         
            +
                    scope.set_transaction_name(context_filter.transaction_name)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    transaction = Sentry.start_transaction(name: scope.transaction_name, op: "sidekiq")
         
     | 
| 
      
 17 
     | 
    
         
            +
                    scope.set_span(transaction) if transaction
         
     | 
| 
       11 
18 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                     
     | 
| 
      
 19 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 20 
     | 
    
         
            +
                      yield
         
     | 
| 
      
 21 
     | 
    
         
            +
                    rescue => e
         
     | 
| 
      
 22 
     | 
    
         
            +
                      finish_transaction(transaction, 500)
         
     | 
| 
      
 23 
     | 
    
         
            +
                      raise
         
     | 
| 
      
 24 
     | 
    
         
            +
                    end
         
     | 
| 
       13 
25 
     | 
    
         | 
| 
      
 26 
     | 
    
         
            +
                    finish_transaction(transaction, 200)
         
     | 
| 
       14 
27 
     | 
    
         
             
                    # don't need to use ensure here
         
     | 
| 
       15 
28 
     | 
    
         
             
                    # if the job failed, we need to keep the scope for error handler. and the scope will be cleared there
         
     | 
| 
       16 
29 
     | 
    
         
             
                    scope.clear
         
     | 
| 
       17 
30 
     | 
    
         
             
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def finish_transaction(transaction, status)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    return unless transaction
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    transaction.set_http_status(status)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    transaction.finish
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
       18 
38 
     | 
    
         
             
                end
         
     | 
| 
       19 
39 
     | 
    
         
             
              end
         
     | 
| 
       20 
40 
     | 
    
         
             
            end
         
     | 
    
        data/sentry-sidekiq.gemspec
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: sentry-sidekiq
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Sentry Team
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-05-03 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: sentry-ruby-core
         
     | 
| 
         @@ -16,14 +16,14 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: 4. 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 4.4.0.pre.beta
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: 4. 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 4.4.0.pre.beta
         
     | 
| 
       27 
27 
     | 
    
         
             
            description: A gem that provides Sidekiq integration for the Sentry error logger
         
     | 
| 
       28 
28 
     | 
    
         
             
            email: accounts@sentry.io
         
     | 
| 
       29 
29 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -49,7 +49,6 @@ files: 
     | 
|
| 
       49 
49 
     | 
    
         
             
            - example/config/sidekiq.yml
         
     | 
| 
       50 
50 
     | 
    
         
             
            - example/error_worker.rb
         
     | 
| 
       51 
51 
     | 
    
         
             
            - lib/sentry-sidekiq.rb
         
     | 
| 
       52 
     | 
    
         
            -
            - lib/sentry/sidekiq/cleanup_middleware.rb
         
     | 
| 
       53 
52 
     | 
    
         
             
            - lib/sentry/sidekiq/context_filter.rb
         
     | 
| 
       54 
53 
     | 
    
         
             
            - lib/sentry/sidekiq/error_handler.rb
         
     | 
| 
       55 
54 
     | 
    
         
             
            - lib/sentry/sidekiq/sentry_context_middleware.rb
         
     | 
| 
         @@ -77,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       77 
76 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       78 
77 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       79 
78 
     | 
    
         
             
            requirements: []
         
     | 
| 
       80 
     | 
    
         
            -
            rubygems_version: 3.0.3
         
     | 
| 
      
 79 
     | 
    
         
            +
            rubygems_version: 3.0.3.1
         
     | 
| 
       81 
80 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       82 
81 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       83 
82 
     | 
    
         
             
            summary: A gem that provides Sidekiq integration for the Sentry error logger
         
     | 
| 
         @@ -1,21 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Sentry
         
     | 
| 
       2 
     | 
    
         
            -
              module Sidekiq
         
     | 
| 
       3 
     | 
    
         
            -
                class CleanupMiddleware
         
     | 
| 
       4 
     | 
    
         
            -
                  def call(_worker, job, queue)
         
     | 
| 
       5 
     | 
    
         
            -
                    return yield unless Sentry.initialized?
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                    Sentry.clone_hub_to_current_thread
         
     | 
| 
       8 
     | 
    
         
            -
                    Sentry.with_scope do |scope|
         
     | 
| 
       9 
     | 
    
         
            -
                      scope.set_extras(sidekiq: job.merge("queue" => queue))
         
     | 
| 
       10 
     | 
    
         
            -
                      scope.set_transaction_name("Sidekiq/#{job["class"]}")
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                      begin
         
     | 
| 
       13 
     | 
    
         
            -
                        yield
         
     | 
| 
       14 
     | 
    
         
            -
                      rescue => ex
         
     | 
| 
       15 
     | 
    
         
            -
                        Sentry::Sidekiq.capture_exception(ex, hint: { background: false })
         
     | 
| 
       16 
     | 
    
         
            -
                      end
         
     | 
| 
       17 
     | 
    
         
            -
                    end
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
            end
         
     |