apm-agent-python icon indicating copy to clipboard operation
apm-agent-python copied to clipboard

#2114 repeating query in django view

Open Pokapiec opened this issue 1 year ago • 4 comments

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

Pokapiec avatar Nov 25 '24 07:11 Pokapiec

💚 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.

Pokapiec avatar Nov 25 '24 07:11 Pokapiec

cla/check

gtback avatar Dec 11 '24 16:12 gtback

@xrmx can you proceed reviewing this PR ?

pawelusermoc avatar Feb 03 '25 09:02 pawelusermoc

@pawelusermoc @Pokapiec pushed another commit to cleanup, does it work for you?

xrmx avatar Jul 07 '25 14:07 xrmx