scout_apm_python icon indicating copy to clipboard operation
scout_apm_python copied to clipboard

Instrument Django Channels

Open adamchainz opened this issue 6 years ago • 3 comments

This issue mostly discussed some bugs relating to async channels behaviour: #46 . It also noted we could instrument Channels better.

We already instrument normal Django views run under Channels because the full Django middleware stack runs. We'd better just look at instrumenting other types of consumers - notably websockets and async http consumers.

adamchainz avatar Nov 08 '19 09:11 adamchainz

@svvitale you were interested in testing a Channels integration. This is the tracking issue.

We've discussed this internally a bit more and tracing a websocket for its entire lifetime probably won't make sense. Traces will be very long and feature a lot of idle time. We'd like to trace only around user interaction but since an await could be doing pretty much anything, it's not possible in the general case to do this.

The integration I started in #412 has some provision to trace standard methods in Channels like WebsocketConsumer.websocket_receive. However these would only trace events from the user side. It's not clear if this would be useful. What would you expect to have traced on Channels @svvitale?

adamchainz avatar Jan 02 '20 10:01 adamchainz

@svvitale has confirmed on Slack that we currently don't track normal Django views that are served through Channels' AsgiHandler. We should investigate that.

adamchainz avatar Apr 10 '20 09:04 adamchainz

I've just tested with my demo channels app, and requests from AsgiHandler are working there (Django 3.0, Channels 2.4.0).

adamchainz avatar Apr 28 '20 09:04 adamchainz