Support for psycopg Composed queries

Open
#749 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
django, postgresql, python

Research direction

Start at src/scout_apm/core/n_plus_one_tracker.py line 29 and reproduce the Django raw-query failure with psycopg2 SQL composition. Trace how the Composed query reaches the instrumentation code; done means the query is instrumented without the TypeError or the workaround that converts it to a string.

Written by the indexing model from the issue text.

Description

The Scout agent breaks when it tries to instrument raw queries in Django that use psycopg2's SQL string composition. Specifically, we get a TypeError: unhashable type: 'Composed' on this line of code:

https://github.com/scoutapp/scout_apm_python/blob/86d14920a59a7a3b5dfffe680586646ee29bdd7a/src/scout_apm/core/n_plus_one_tracker.py#L29

I created a workaround that converts the query to a raw string before executing it, however it involves getting a cursor and compiling the string before doing the actual query. That's more overhead than I would prefer, so it would be really nice if Scout were able to support Composed as well.

Dominant language
Python
Stars
77
Forks
19
Avg merge
1d 9h
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scoutapp/scout_apm_python

All issues in scoutapp/scout_apm_python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.