newrelic-python-agent
newrelic-python-agent copied to clipboard
Instrumented libraries not reported when called from run_in_executor
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:
