SDK Fingerprinting
In supported SDKs, you can override the Sentry default grouping passing the fingerprint attribute an array of strings. This works similar to the server side functionality which is always available and
can achieve similar results.
You can use variable substitution to fill dynamic values into the fingerprint that are normally computed on the server. For instance, the value {{ default }} can be added to add the entire normally generated grouping hash into the fingerprint. These values are the same as for server side fingerprinting. See Variables for more information.
Group Errors With Greater Granularity
Your application queries an RPC interface or external API service, so the stack trace is generally the same (even if the outgoing request is very different).
The following example will split up the default group Sentry would create (represented by {{ default }}) further, taking some attributes on the error object into account:
type MyRPCError struct {
message string
functionName string
errorCode int
}
func (e MyRPCError) Error() string {
return "MyRPCError: " + e.message
}
func (e MyRPCError) ErrorCode() string {
return strconv.Itoa(e.errorCode)
}
func (e MyRPCError) FunctionName() string {
return e.functionName
}
sentry.Init(sentry.ClientOptions{
// ...
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
if ex, ok := hint.OriginalException.(MyRPCError); ok {
event.Fingerprint = []string{"{{ default }}", ex.ErrorCode(), ex.FunctionName()}
}
return event
},
})Group Errors More Aggressively
A generic error, such as a database connection error, has many different stack traces and never groups together.
The following example will just completely overwrite Sentry's grouping by omitting {{ default }} from the array:
type DatabaseConnectionError struct {
message string
}
func (e DatabaseConnectionError) Error() string {
return e.message
}
sentry.Init(sentry.ClientOptions{
// ...
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
if ex, ok := hint.OriginalException.(DatabaseConnectionError); ok {
event.Fingerprint = []string{"database-connection-error"}
}
return event
},
})- Package:
- github:getsentry/sentry-go
- Version:
- 0.7.0
- Repository:
- https://github.com/getsentry/sentry-go/