Skip to content

Commit 452273d

Browse files
tustanivskysfanahata
authored andcommitted
Unreal Engine: Add event fingerprint API docs (#13808)
This PR adds docs for the new event class API that allows get/set its fingerprint. Corresponding changes were introduced to Unreal SDK in scope of getsentry/sentry-unreal#920. Closes #13733 --------- Co-authored-by: Shannon Anahata <[email protected]>
1 parent 5e6575a commit 452273d

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "SDK Fingerprinting"
3+
description: "Learn about overriding default fingerprinting in your SDK."
4+
sidebar_order: 30
5+
---
6+
7+
All events have a fingerprint. Events with the same fingerprint are grouped together into an issue.
8+
9+
By default, Sentry will run one of our built-in grouping algorithms to generate a fingerprint based on information available within the event such as `stacktrace`, `exception`, and `message`. To extend the default grouping behavior or change it completely, you can use a combination of the following options:
10+
11+
1. In your SDK, using SDK Fingerprinting, as documented below
12+
2. In your project, using [Fingerprint Rules](/concepts/data-management/event-grouping/fingerprint-rules/) or [Stack Trace Rules](/concepts/data-management/event-grouping/stack-trace-rules/)
13+
14+
In supported SDKs, you can override Sentry's default grouping that passes the fingerprint attribute as an array of strings. The length of a fingerprint's array is not restricted. This works similarly to the [fingerprint rules functionality](/concepts/data-management/event-grouping/fingerprint-rules/), which is always available and can achieve similar results.
15+
16+
## Basic Example
17+
18+
In the most basic case, values are passed directly:
19+
20+
<PlatformContent includePath="set-fingerprint/basic" />
21+
22+
You can use variable substitution to fill dynamic values into the fingerprint that by default is computed on the server. For example, the value `{{ default }}` can be added to include the entire normally generated grouping hash into the fingerprint. These values are the same for server-side fingerprinting. See [Variables](/concepts/data-management/event-grouping/fingerprint-rules/#variables) for more information.
23+
24+
## Group Errors With Greater Granularity
25+
26+
In some scenarios, you'll want to group errors more granularly.
27+
28+
For example, if your application queries a Remote Procedure Call Model (RPC) interface or external Application Programming Interface (API) service, the stack trace is generally the same, even if the outgoing request is very different.
29+
30+
The following example will split up the default group Sentry would create (represented by `{{ default }}`) even more, taking some attributes on the error object into account:
31+
32+
<PlatformContent includePath="set-fingerprint/rpc" />
33+
34+
## Group Errors More Aggressively
35+
36+
You can also overwrite Sentry's grouping entirely.
37+
38+
For example, if a generic error, such as a database connection error, has many different stack traces and never groups them together, you can overwrite Sentry's grouping by omitting `{{ default }}` from the array:
39+
40+
<PlatformContent includePath="set-fingerprint/database-connection" />
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```cpp
2+
FHttpModule* Http = &FHttpModule::Get();
3+
TSharedRef<IHttpRequest, ESPMode::ThreadSafe> HttpRequest = Http->CreateRequest();
4+
5+
// Configure the request
6+
HttpRequest->SetURL(URL);
7+
HttpRequest->SetVerb("POST");
8+
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
9+
HttpRequest->SetContentAsString(JsonString);
10+
HttpRequest->OnProcessRequestComplete().BindLambda([=](FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
11+
{
12+
if (bWasSuccessful && Response.IsValid() && Response->GetResponseCode() != 200)
13+
{
14+
// Handle successful response
15+
}
16+
else
17+
{
18+
TArray<FString> Fingerprint;
19+
Fingerprint.Add("http-request-error");
20+
Fingerprint.Add(Request->GetURL());
21+
Fingerprint.Add(Request->GetVerb());
22+
23+
// Add more context if needed
24+
25+
USentryEvent* Event = NewObject<USentryEvent>();
26+
Event->Initialize();
27+
Event->SetFingerprint(Fingerprint);
28+
29+
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
30+
SentrySubsystem->CaptureEvent(Event, ESentryLevel::Error);
31+
}
32+
});
33+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
```cpp
2+
USentryEvent* Event = NewObject<USentryEvent>();
3+
Event->Initialize();
4+
Event->SetFingerprint( { "database-connection-error" } );
5+
6+
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
7+
SentrySubsystem->CaptureEvent(Event, ESentryLevel::Error);
8+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
```cpp
2+
USTRUCT()
3+
struct FSomeRpcError
4+
{
5+
GENERATED_BODY()
6+
7+
UPROPERTY()
8+
FString Function;
9+
UPROPERTY()
10+
FString Code;
11+
}
12+
13+
// Some code that emits RPC error info
14+
FSomeRpcError RpcError = /* ... */
15+
16+
USentryEvent* Event = NewObject<USentryEvent>();
17+
Event->Initialize();
18+
Event->SetFingerprint( { "{{ default }}", RpcError.Function, RpcError.Code } );
19+
20+
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
21+
SentrySubsystem->CaptureEvent(Event, ESentryLevel::Error);
22+
```

0 commit comments

Comments
 (0)