Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ActionCable support #309

Merged
merged 5 commits into from
Jun 15, 2017
Merged

Add ActionCable support #309

merged 5 commits into from
Jun 15, 2017

Conversation

tombruijn
Copy link
Member

@tombruijn tombruijn commented Jun 8, 2017

Support ActionCable by overriding the #perform_action method and
wrapping it in an AppSignal transaction. The #perform_action is called
by ActionCable once a message is send to the channel.

We also track subscribe and unsubscribe events as they can also contain
complex logic added by the user, which is something we want to track. To
track this two "around" callbacks are added to ActionCable on load.

I've added an example application here for you to test it against: https://github.com/appsignal/appsignal-examples/tree/rails-5%2Baction-cable

Transactions are tested with the data from the extension as per issue #252

Support

https://app.intercom.io/a/apps/yzor8gyw/respond/inbox/conversation/9011790920
https://app.intercom.io/a/apps/yzor8gyw/respond/inbox/conversation/9039706354


Note: Rebased continuation of #275, which I'll close after creating this. Rebased the branch and created a new PR, because I had to rebase it to clean up some really old work that was extracted to separate PRs and things that really weren't necessary anymore. I also didn't want to rebase the original PR and force push it, in case someone is relying on it, breaking their build.

Support ActionCable by overriding the `#perform_action` method and
wrapping it in an AppSignal transaction. The `#perform_action` is called
by ActionCable once a message is send to the channel.

We also track subscribe and unsubscribe events as they can also contain
complex logic added by the user, which is something we want to track. To
track this two "around" callbacks are added to ActionCable on load.
@tombruijn tombruijn self-assigned this Jun 8, 2017
@tombruijn tombruijn mentioned this pull request Jun 8, 2017
3 tasks
Otherwise the event timeline would only show up if custom/other
instrumentation was added/is active. They would be listed without a
related (ActionCable) parent event.
@tombruijn
Copy link
Member Author

Small update: Added instrumentation around callbacks so that they always have one action cable event.

@tombruijn tombruijn added this to the 2.3 milestone Jun 8, 2017
allow(Appsignal::Transaction).to receive(:current).and_return(transaction)
expect(transaction.ext).to receive(:complete) # and do nothing

# TODO: Nicer way to stub this without a websocket?
Copy link
Member

Choose a reason for hiding this comment

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

Could you remove this TODO and create an issue for it, so it doesn't get lost?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, that TODO. I wanted to fix that before submitting it, but looks like it slipped through. I'll have a looksy

Copy link
Member Author

Choose a reason for hiding this comment

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

Explained the comment a bit better, but I'll leave the stub like this for now.

tombruijn added 2 commits June 8, 2017 17:39
Can't find a way to easily create a websocket class for ActionCable.
Instead, I'll leave it like this. Best thing to do is create a higher
level integration test, but this will do for now.
@tombruijn tombruijn removed this from the 2.3 milestone Jun 12, 2017
@tombruijn
Copy link
Member Author

Looks like this doesn't support standalone mode at the moment: http://edgeguides.rubyonrails.org/action_cable_overview.html#standalone

Standalone ActionCable servers don't have an ActionDispatch request_id
in the request env. Instead, we create our own and add it to the request
under a private key. This key is then used to save the request id, also
for non-standalone servers, and reused throughout the duration of the
websocket. This allows us to track all messages on a websocket under the
same request_id. This could make searching for all samples on one
websocket connection a lot easier.
Copy link
Member

@thijsc thijsc left a comment

Choose a reason for hiding this comment

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

Nice!

@thijsc thijsc merged commit b46be6b into develop Jun 15, 2017
@thijsc thijsc deleted the action_cable-support-reworked branch June 15, 2017 07:33
@rmachielse
Copy link

👌 @tombruijn thanks a lot for this

@p0wl
Copy link

p0wl commented Jun 15, 2017

very nice 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants