Custom grouping only needs an error span and an error.fingerprint
string span tag.
If you aren’t already collecting APM traces with Datadog, see the APM documentation to set up APM.
Example
If you’re already sending APM spans, add a new error.fingerprint
tag to your error span.
Here’s an example in Python:
with tracer.trace("throws.an.error") as span:
span.set_tag('error.fingerprint', 'my-custom-grouping-material')
raise Exception("Something went wrong")
Exception information is captured and attached to a span if there is one active when the exception is raised.
In this case, my-custom-grouping-material
is used to group these error spans into a single
issue in Error Tracking.
Custom grouping only needs an error log and an error.fingerprint
string attribute.
If you aren’t already collecting logs with Datadog, see the Log Management documentation to set up logs.
Ensure that the source
tag (specifying language) is properly configured.
Example
If you’re already logging in JSON format, add a new error.fingerprint
attribute to your error log.
Here’s an example in Python for a JSON-formatted logger:
import logging
import json_log_formatter
formatter = json_log_formatter.JSONFormatter()
json_handler = logging.FileHandler(filename='/var/log/my-log.json')
json_handler.setFormatter(formatter)
logger = logging.getLogger('my_json')
logger.addHandler(json_handler)
logger.setLevel(logging.INFO)
logger.error('Error processing request', extra={'error.fingerprint': 'my-custom-grouping-material'})
In this case, my-custom-grouping-material
is used to group these error logs into a single
issue in Error Tracking.
In order to use custom grouping, you need the Datadog Browser SDK v4.42.0 or later, a browser RUM error, and an additional string attribute.
If you aren’t already collecting Browser RUM events with Datadog, see the Browser Monitoring setup documentation.
Example
If you’re already collecting browser errors, it’s possible to add the attribute by either:
- Adding a
dd_fingerprint
attribute to the error object:
import { datadogRum } from '@datadog/browser-rum';
// Send a custom error with context
const error = new Error('Something went wrong');
error.dd_fingerprint = 'my-custom-grouping-fingerprint'
datadogRum.addError(error);
- Or, using the
beforeSend
callback with an error.fingerprint
attribute:
DD_RUM.init({
...
beforeSend: () => {
if (event.type === 'error') {
event.error.fingerprint = 'my-custom-grouping-fingerprint'
}
},
})
In both cases, my-custom-grouping-material
is used to group the Browser RUM errors into a single issue in Error Tracking.