Skip to content

Commit

Permalink
Added rails and actioncable exceptions, and moved changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
natikgadzhi committed Jan 4, 2024
1 parent 7afd73d commit d8891f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

- Pick up config.cron.default_timezone from Rails config ([#2213](https://github.com/getsentry/sentry-ruby/pull/2213))

### Bug Fixes

- Sentry will not record traces of HTTP OPTIONS and HEAD requests in Rack and Rails apps [#2181](https://github.com/getsentry/sentry-ruby/pull/2181)

## 5.15.2

### Bug Fixes
Expand Down Expand Up @@ -65,7 +69,6 @@
### Bug Fixes

- Network errors raised in `Sentry::HTTPTransport` will no longer be reported to Sentry [#2178](https://github.com/getsentry/sentry-ruby/pull/2178)
- Sentry will not record traces of HTTP OPTIONS and HEAD requests in Rack and Rails apps [#2181](https://github.com/getsentry/sentry-ruby/pull/2181)

## 5.14.0

Expand Down
3 changes: 3 additions & 0 deletions sentry-rails/lib/sentry/rails/action_cable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Rails
module ActionCableExtensions
class ErrorHandler
OP_NAME = "websocket.server".freeze
IGNORED_HTTP_METHODS = ["HEAD", "OPTIONS"].freeze

class << self
def capture(connection, transaction_name:, extra_context: nil, &block)
Expand Down Expand Up @@ -33,6 +34,8 @@ def capture(connection, transaction_name:, extra_context: nil, &block)
end

def start_transaction(env, scope)
return nil if IGNORED_HTTP_METHODS.include?(env["REQUEST_METHOD"])

options = { name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME }
transaction = Sentry.continue_trace(env, **options)
Sentry.start_transaction(transaction: transaction, **options)
Expand Down
3 changes: 3 additions & 0 deletions sentry-rails/lib/sentry/rails/capture_exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Sentry
module Rails
class CaptureExceptions < Sentry::Rack::CaptureExceptions
RAILS_7_1 = Gem::Version.new(::Rails.version) >= Gem::Version.new("7.1.0.alpha")
IGNORED_HTTP_METHODS = ["HEAD", "OPTIONS"].freeze

def initialize(_)
super
Expand Down Expand Up @@ -32,6 +33,8 @@ def capture_exception(exception, env)
end

def start_transaction(env, scope)
return nil if IGNORED_HTTP_METHODS.include?(env["REQUEST_METHOD"])

Check warning on line 36 in sentry-rails/lib/sentry/rails/capture_exceptions.rb

View check run for this annotation

Codecov / codecov/patch

sentry-rails/lib/sentry/rails/capture_exceptions.rb#L36

Added line #L36 was not covered by tests

options = { name: scope.transaction_name, source: scope.transaction_source, op: transaction_op }

if @assets_regexp && scope.transaction_name.match?(@assets_regexp)
Expand Down

0 comments on commit d8891f3

Please sign in to comment.