• Log inStart now

profile_trace (Python agent API)

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.

Important

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

name

string

Optional. The function name. If not set, defaults to the captured name of the function.

group

string

Optional. The group represents the naming structure for the name parameter. This is used in the UI for segregating the transaction types.

If not supplied, the group will default to Function in expectation that the name is of the form module:class.function or module:function and represents the name of the function being executed. If you are creating a custom group, it's recommended you prefix it with Python/.

label

string

Optional. Adds a callout-style flag to the segment in a transaction trace. Default is None.

params

dict

Optional. Custom parameters to add to the segment in transaction traces.

depth

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

wrapped

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()
...
Copyright © 2022 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.