Skip to content

Capture exceptions in Action Cable connections and channels (continuation of #1295)#1638

Merged
st0012 merged 9 commits intogetsentry:masterfrom
choznerol:rails-action-cable-support
Dec 12, 2021
Merged

Capture exceptions in Action Cable connections and channels (continuation of #1295)#1638
st0012 merged 9 commits intogetsentry:masterfrom
choznerol:rails-action-cable-support

Conversation

@choznerol
Copy link
Copy Markdown
Contributor

@choznerol choznerol commented Dec 9, 2021

Description

Close #470

This is a continuation of #1295 (#1295 (comment))

Most of the features are already done in #1295, I only added:

  1. Update according to latest review comments Capture exceptions in Action Cable connections and channels #1295 (review).
  2. Capture exceptions in Action Cable connections and channels #1295 integrates with Rails similar to how Sentry::Rails::ActiveJobExtensions did. When resolving conflict with the latest master, however, I realized the latter has changed a lot in Only extend ActiveJob when it's defined #1218 and Use ActiveSupport Lazy Load Hook to Apply ActiveJob Extension #1494. I try to update Sentry::Rails::ActionCableExtensions in a similar fashion to prevent bugs like sentry + eager_load breaks ActiveJob rescue_from #1249.

There are 5 types of hooks that Action Cable provides:

* `Connection#connect`
* `Connection#disconnect`
* `Channel#subscribed`
* `Channel#unsubscribed`
* `Channel` actions

Now, any exceptions raised within those hooks are captured by Sentry, and reported as `ActionCable/[...]` transactions. Additional context is included depending on the hook the exception was raised within.

A note/quirk: the Rack env that's included in the scope is from the `Connection`, and therefore has a URL of the cable `mount_path` (usually `/cable`) as well as the headers from that initial connection request.

Additionally, there is not currently a really clean way to hook in and set `user_context`. I don't know if that is a blocker for this integration, but wanted to make sure it was noted.
choznerol added a commit to choznerol/sentry-ruby that referenced this pull request Dec 9, 2021
@choznerol choznerol force-pushed the rails-action-cable-support branch from 5ddc80c to a5cadc9 Compare December 9, 2021 15:00
choznerol added a commit to choznerol/sentry-ruby that referenced this pull request Dec 9, 2021
@choznerol choznerol force-pushed the rails-action-cable-support branch from a5cadc9 to ad612c9 Compare December 9, 2021 15:06
choznerol added a commit to choznerol/sentry-ruby that referenced this pull request Dec 9, 2021
@choznerol choznerol force-pushed the rails-action-cable-support branch from ad612c9 to 26d0aa0 Compare December 9, 2021 15:15
@choznerol choznerol marked this pull request as ready for review December 9, 2021 15:16
@choznerol choznerol force-pushed the rails-action-cable-support branch from 26d0aa0 to d09d114 Compare December 10, 2021 04:25
@st0012 st0012 added this to the 4.9.0 milestone Dec 12, 2021
Copy link
Copy Markdown
Contributor

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@choznerol @agrobbin thanks for adding this feature!

@st0012 st0012 merged commit ce10521 into getsentry:master Dec 12, 2021
@choznerol choznerol deleted the rails-action-cable-support branch December 13, 2021 01:47
@agrobbin
Copy link
Copy Markdown
Contributor

Awesome, thanks @choznerol @st0012!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActionCable probably doesn't work

3 participants