Skip to content

Intermittent Client AttributeError with Django integration #1093

Closed
@ccorbacho

Description

@ccorbacho

Describe the bug:

We are sometimes seeing this traceback via Sentry coming from the elasticapm agent with the Django integration:

AttributeError: 'Client' object has no attribute 'get_data_from_request'
  File "elasticapm/contrib/django/middleware/__init__.py", line 179, in process_response
    elasticapm.set_context(
  File "elasticapm/traces.py", line 848, in set_context
    data = data()
  File "elasticapm/contrib/django/middleware/__init__.py", line 180, in <lambda>
    lambda: self.client.get_data_from_request(request, constants.TRANSACTION), "request"

To Reproduce

Environment (please complete the following information)

  • OS: Linux
  • Python version: 3.8.9
  • Framework and version [e.g. Django 2.1]: Django 3.1.7
  • APM Server version: 7.6
  • Agent version: 6.1.1

Additional context

There is nothing else in the Sentry exception that gives more context - from the exception and a quick look at the agent code, I imagine there must be some code path that allows the base Client object to be passed through instead of DjangoClient when using the Django integration?

Most of these exceptions (according to Sentry) are coming from requests to a container health check endpoint, which doesn't make any DB connections or do anything with models, it's just a simple view that returns a string to confirm that Gunicorn is up and running and can serve requests.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions