Sometimes, you will notice that most of the time is spent in your app occurring in 3rd party packages . For instances you might see in your transaction traces a lot of time spent in “Application code” :
Application code () :
When you want to instrument/configure your Python app to get a deeper visibility into your application function, kindly follow the steps below:
Add function traces to those 3rd party packages using the transaction_tracer.function_trace setting in the
newrelic.inifile. As long as the values are
module:Class.functionthe agent will be able to instrument it!
Use the Thread profiler to get 3rd party abstracted calls. This will show you how much time is being spent in each method as a percentage of total-time across all transactions.
newrelic.agent.profile_tracedecorator. This api is experimental and undocumented. It will add function traces to all functions called by one decorated up to a given depth. This could add additional unneeded overhead. Therefore, we would highly suggest removing the decorator once the performance problem has been located. Here’s an example usage:
@newrelic.agent.profile_trace(depth=3) def save(): # 3rd party function calls from packages/libs
Let us know if you have any thoughts or questions.