Syntax
newrelic.agent.set_error_group_callback(callback_function(exception, transaction_data))
This method allows error groups within the errors inbox to be set to a specific identifier (or "fingerprint").
Requirements
Python agent version 8.8.0 or higher.
Description
This endpoint takes in a single input, a callback, which is used to register error groups. This callback is customer-defined and must accept the exception that triggered the agent's notice_error
API. To unset this setting, call the API again and set the callback to None
.
Parameters for set_error_group_callback
Parameter | Description |
---|---|
callable function | Required. The callback function you want to define. Use |
Application Instance | Optional. If an application instance is not provided, the function will check for the activated application instance. |
Parameters for customer defined callback function
Parameter | Description |
---|---|
Runtime exception | Required. This would be the runtime exception that triggered the agent's |
dictionary | Required. A dictionary of transaction data captured by the Python agent. |
Return values
When successful, the API will add a string representing the desired error group name as an agent attribute.
When unsuccessful, the API will not add error.group.name
as an agent attribute.
Example usage
Set error group callback
An example of using set_error_group_callback
:
def customer_callback(exc, data): if isinstance(exc, ValueError): return "group1"
def some_other_function(): try: raise ValueError("Oh no!") except Exception: newrelic.agent.notice_error()
def example_function(customer_callback): try: newrelic.agent.set_error_group_callback(customer_callback) some_other_function() finally: newrelic.agent.set_error_group_callback(None)