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

Instrumented libraries not reported when called from run_in_executor

Open GabrielCappelli opened this issue 3 years ago • 0 comments

Description Instrumentation of module works, but if call is wrapped in loop_run_in_executor then it no longer works.

For example, using mysqlclient database, this works fine:

database.connect().execute("select sleep(2)") # Shows up as MySQL on NR

But if I use run_in_executor then it's not detected properly:

await asyncio.get_running_loop().run_in_executor(
    None, lambda: database.connect().execute("select sleep(2)")
) # Shows up as Python on  NR

Expected Behavior

NewRelic would detect MySQL calls regardless of whether they were executed in run_in_executor

Troubleshooting or NR Diag results

Steps to Reproduce

Use run_in_executor to execute code for a instrumented library

Your Environment

Python 3.10.7

sanic 22.9.0

newrelic 8.2.1

Additional context

Both transaction as they were reported in NR: image

GabrielCappelli avatar Oct 11 '22 17:10 GabrielCappelli