dd-trace-py icon indicating copy to clipboard operation
dd-trace-py copied to clipboard

Duplicate logging of requests: Gunicorn and Django

Open tony opened this issue 1 year ago • 0 comments
trafficstars

Both Gunicorn and Django log incoming requests, which can lead to duplicate request entries.

Question

Is there a reference or best practice for configuring both the HTTP server and Python applications to avoid this?

Problem

Gunicorn doesn’t support separate service names

As of v2.11.3, Gunicorn does not allow specifying a separate custom service name for its logs (please correct me if I’ve misunderstood this). Django and GraphQL do.

Expected behavior

I believe downstream users would expect a setup like the following:

  • {service_name}-gunicorn: For HTTP server requests (handled by Gunicorn)
  • {service_name}: For the application layer (e.g., Django)

This configuration would enable tracing the flow of requests through the entire stack: HTTP Server (Gunicorn) → App (e.g., Django) → Database (e.g., Redis/Postgres) or other external services.

Appendix

Similar closed thread:

  • https://github.com/DataDog/dd-trace-py/issues/5636 (not gunicorn related, but django with properly connected traces is easy to get stuck on, if not using ddtrace-run.)

tony avatar Sep 07 '24 11:09 tony