apm-agent-python
apm-agent-python copied to clipboard
#2114 repeating query in django view
What does this pull request do?
In this PR i add another condition to elif statement in utils.encoding.transform function to handle displaying representation of django QuerySet object in custom way. We need to do it because if we try to execute repr function on unexecuted QuerySet which causes Timeout on database, it will execute by utils.encoding.transform function.
I also added a simple test simulating database Timeout.
By overwriting _result_cache on django QuerySet object we ensure that django will not try to execute any query to db.
Related issues
Closes #2114
💚 CLA has been signed
@xrmx this is the PR i created to resolve this issue https://github.com/elastic/apm-agent-python/issues/2114 we discussed earlier. I wanted to add this transformation logic to django contrib code but i couldn't make it work so i had to move it to transform func. Let me know if there is a better way.
cla/check
@xrmx can you proceed reviewing this PR ?
@pawelusermoc @Pokapiec pushed another commit to cleanup, does it work for you?