• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

set_error_group_callback (Python agent API)

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

callback

callable function

Required. The callback function you want to define. Use None to unset.

application

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

exception

Runtime exception

Required. This would be the runtime exception that triggered the agent's notice_error API.

transaction_data

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

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