Syntax
newrelic.agent.profile_trace(name=None, group=None, label=None, params=None, depth=3)
Adds additional attributes to function trace names.
Description
profile_trace
is used to add more detail to your transaction traces in the form of additional segments. Any calls reported with profile_trace
will appear on the APM Databases page. profile_trace
returns a partial of ProfileTraceWrapper
that can be used as a decorator for a function to time calls to your profiler.
If you cannot use the decorator in your application, you can use the following call format: The wrapper form is ProfileTraceWrapper
. It can be used to return a wrapped function without the use of a decorator.
For an explanation of the uses of these different call formats, see Different call formats. See Examples for call examples.
Importante
Functions are only instrumented in the scope of the specified function call. If a funtion function_a
is traced and it calls function_b
this will only be instrumented within the scope of function_a
and not anywhere else where function_b
is called but not traced.
Parameters
Parameters for decorator
newrelic.agent.profile_trace(name=None, group=None, label=None, params=None, depth=3)
This call includes these parameters:
Parameter | Description |
---|---|
string | Optional. The function name. If not set, defaults to the captured name of the function. |
string | Optional. The If not supplied, the group will default to |
string | Optional. Adds a callout-style flag to the segment in a transaction trace. Default is |
dict | Optional. Custom parameters to add to the segment in transaction traces. |
dict | Optional. Parameter for maximum function trace depth. Default is 3. |
Wrapper parameters
newrelic.agent.ProfileTraceWrapper(wrapped, name=None, group=None, label=None, params=None, depth=3)
Parameters for the wrapper include all parameters for profile_trace
and a wrapped
parameter:
Parameter | Description |
---|---|
function | Required. The function being wrapped. |
Examples
profile_trace
example
An example of using the profile_trace
decorator:
import newrelic.agent
@newrelic.agent.profile_trace()def some_function(): ...
Wrapper example
An example of using the ProfileTraceWrapper
:
import newrelic.agent
def another_function(): wrapped_function = newrelic.agent.ProfileTraceWrapper(some_function) ... wrapped_function() ...