NewRelic Ruby Agent: errors not ignored
<p>In a Sidekiq worker I want to ignore some errors in NewRelic while still raising them so that Sidekiqs retry behaviour kicks in.
I wrote a helper class to call <code>NewRelic::Agent.ignore_transaction</code> but still NewRelic reports these exceptions and complains about the error rate. What am I doing wrong?
I guess that I may have misunderstood something about the scope of the transaction?</p>

<pre><code>module NewRelic
  # Run a block which rescues some exceptions and ignores them in NewRelic
  class IgnoreExceptions
    class &lt;&lt; self
      def ignore(*class_list)
        raise ArgumentError, 'Block required' unless block_given?
        begin
          yield
        rescue errors_matching { |e| class_list.include?(e.class) }
          NewRelic::Agent.ignore_transaction
          raise
        end
      end

      private

      def errors_matching(&amp;block)
        Module.new.tap { |m| m.define_singleton_method(:===, &amp;block) }
      end
    end
  end
end
</code></pre>