SDK Fingerprinting

In supported SDKs, you can override the Sentry default grouping passing the fingerprint attribute an array of strings. The length of a fingerprint's array is not restricted. This works similarly to the server-side functionality, which is always available and can achieve similar results.

Basic Example

In the most basic of cases, values are passed directly:

Copied
#include <sentry.h>

void send_request(request_t *req) {
    response_t *resp = request_send(req);

    if (response_failed(resp)) {
        sentry_value_t fp = sentry_value_new_list();
        sentry_value_append(fp, sentry_value_new_string(req->method));
        sentry_value_append(fp, sentry_value_new_string(req->path));
        sentry_value_append(fp, sentry_value_new_string(resp->status));

        sentry_value_t event = sentry_value_new_event();
        sentry_value_set_by_key(event, "fingerprint", fp);

        // create an event here

        sentry_capture_event(event);
    }
}

You can use variable substitution to fill dynamic values into the fingerprint generally 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 a Remote Procedure Call Model (RPC) interface or external Application Programming Interface (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:

Copied
#include <string>
#include <sentry.h>

class MyRpcError {
   public:
    std::string function;
    std::string error_code;

    MyRpcError(std::string function, std::string error_code)
        : function(function), error_code(error_code) {
    }
};

int main() {
    /* some code that emits MyRpcError */
    MyRpcError e(/* ... */);

    sentry_value_t fingerprint = sentry_value_new_list();
    sentry_value_append(fingerprint, sentry_value_new_string("{{ default }}"));
    sentry_value_append(fingerprint, sentry_value_new_string(e.function.c_str()));
    sentry_value_append(fingerprint, sentry_value_new_string(e.error_code.c_str()));

    sentry_value_t event = sentry_value_new_event();
    sentry_value_set_by_key(event, "fingerprint", fingerprint);
    /* add more attributes... */
    sentry_capture_event(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 completely overwrite Sentry's grouping by omitting {{ default }} from the array:

Copied
#include <sentry.h>

sentry_value_t fingerprint = sentry_value_new_list();
sentry_value_append(
    fingerprint, sentry_value_new_string("database-connection-error"));

sentry_value_t event = sentry_value_new_event();
sentry_value_set_by_key(event, "fingerprint", fingerprint);
/* add more attributes... */
sentry_capture_event(event);
You can edit this page on GitHub.