Skip to content

Commit 0f38b17

Browse files
authored
Unreal Engine: Tracing API docs update (#14877)
This PR documents that transactions and spans can be automatically linked to captured errors/events in Unreal Engine. Related to getsentry/sentry-unreal#1075
1 parent bac141a commit 0f38b17

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

docs/platforms/unreal/tracing/instrumentation/custom-instrumentation.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ To capture transactions and spans customized to your organization's needs, you m
1414

1515
<PlatformContent includePath="performance/add-spans-example" />
1616

17+
<PlatformContent includePath="performance/connect-errors-spans" />
18+
1719
<PlatformContent includePath="performance/improving-data" />
1820

1921
## Distributed Tracing
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## Connect Errors With Spans
2+
3+
Sentry errors can be linked to transactions and spans. Errors that are sent to Sentry while the transaction or span bound to the scope is running, will be linked automatically.
4+
5+
By default, transactions and spans are not bound to the scope. To bind them, you must explicitly pass `true` to the `BindToScope` parameter when calling `USentrySubsystem::StartTransaction`, `USentryTransaction::StartChildSpan` or `USentrySpan::StartChild` functions.
6+
7+
```cpp
8+
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
9+
10+
// Transaction bound to the current scope
11+
USentryTransaction* transaction = SentrySubsystem->StartTransaction(
12+
TEXT("transaction name"),
13+
TEXT("transaction operation"),
14+
true
15+
);
16+
17+
// Child span bound to the current scope
18+
USentrySpan* span = transaction->StartChildSpan(
19+
TEXT("span name"),
20+
TEXT("span description"),
21+
true
22+
);
23+
24+
USentryEvent* ErrorEvent = NewObject<USentryEvent>();
25+
ErrorEvent->Initialize();
26+
ErrorEvent->SetLevel(ESentryLevel::Error);
27+
ErrorEvent->SetMessage(TEXT("Error message"));
28+
29+
// Error event will be linked to the span
30+
SentrySubsystem->CaptureEvent(ErrorEvent);
31+
32+
span->Finish();
33+
transaction->Finish();
34+
```

0 commit comments

Comments
 (0)