elastic / apm-agent-python

https://www.elastic.co/guide/en/apm/agent/python/current/index.html
BSD 3-Clause "New" or "Revised" License
415 stars 220 forks source link

Django Channels Websocket Trace #2123

Open abhinavsingh opened 2 months ago

abhinavsingh commented 2 months ago

Describe the bug:

I was expecting APM to help me understand whats going within my websocket connections (Django + Channels + Daphne). However, the very first line of ASGITracingMiddleware ignores non-http scopes:

async def __call__(self, scope: "Scope", receive: "ASGIReceiveCallable", send: "ASGISendCallable") -> None:
        if scope["type"] != "http":
            await self._app(scope, receive, send)
            return

To Reproduce

  1. Install elastic-apm
  2. Configure ELASTIC_APM settings
  3. Configure ASGITracingMiddleware middleware
  4. Kibana shows the service name but no traces

Environment (please complete the following information)

Django==4.2.11
channels==4.0.0
channels-redis==4.1.0
daphne==4.1.0
elastic-apm==6.23.0
elastic-transport==8.15.0
elasticsearch==8.15.0

Is this expected or a bug?

Thank you Abhinav

xrmx commented 2 months ago

Thanks for reporting, given that there is a specific guard for skipping it I would say it's expected. Agree that adding support for tracing websocket may be helpful though.