Skip to content

[Unreal] Add transaction and span set_data documentation #14599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ To capture transactions and spans customized to your organization's needs, you m

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

<PlatformContent includePath="performance/improving-data" />

## Distributed Tracing

In order to use distributed tracing, follow the <PlatformLink to="/tracing/trace-propagation/custom-instrumentation/">custom instrumentation</PlatformLink> steps.
35 changes: 35 additions & 0 deletions platform-includes/performance/improving-data/unreal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Improving Data on Transactions and Spans

### Adding Data Attributes to Transactions

You can add data attributes to your transactions. This data is visible and __queryable__ in the trace explorer in Sentry. Data attributes can be of type _string_, _number_ or _boolean_, as well as arrays and maps of these types:

```cpp
USentryTransaction* transaction = SentrySubsystem->StartTransaction(TEXT("Automation transaction"), TEXT("Automation operation"));

transaction->SetData(TEXT("key"), {{TEXT("data_key1"), TEXT("value")}});
transaction->SetData(TEXT("key"), {{TEXT("data_key2"), 123}});
transaction->SetData(TEXT("key"), {{TEXT("data_key3"), 123.456f}});
transaction->SetData(TEXT("key"), {{TEXT("data_key4"), TArray<FSentryVariant>{{123, 456}}}});
transaction->SetData(TEXT("key"), {{TEXT("data_key5"), TMap<FString, FSentryVariant>{{TEXT("inner_key1"), 123}}}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential bug: The Unreal `SetData` documentation example incorrectly uses the same key for multiple calls, which will cause data to be overwritten, with only the last value being saved.
  • Description: The code examples for SetData in the Unreal documentation repeatedly use the same key, TEXT(&quot;key&quot;), for multiple calls. Standard key-value map behavior, which Unreal's TMap follows, dictates that using the same key overwrites the previous value. Consequently, if a user implements this example, only the data from the final SetData call will be preserved on the transaction, and all previously set attributes will be lost. This contradicts the documentation's stated goal of demonstrating how to add multiple, queryable data attributes and is inconsistent with examples for all other Sentry SDKs.
  • Suggested fix: Update the code examples in the documentation to use a unique key for each SetData call. For instance, use keys like TEXT(&quot;data_key1&quot;), TEXT(&quot;data_key2&quot;), etc., to align with the intended functionality and the pattern established in other Sentry SDK documentation.
    severity: 0.45, confidence: 0.98

Did we get this right? 👍 / 👎 to inform future reviews.


transaction->Finish();
```

### Adding Data Attributes to Spans

You can add data attributes to your transactions. This data is visible and __queryable__ in the trace explorer in Sentry. Data attributes can be of type _string_, _number_ or _boolean_, as well as arrays and maps of these types:

```cpp
USentryTransaction* transaction = SentrySubsystem->StartTransaction(TEXT("Automation transaction"), TEXT("Automation operation"));
USentrySpan* span = transaction->StartChildSpan(TEXT("Automation span"), TEXT("Description text"));

span->SetData(TEXT("key"), {{TEXT("data_key1"), TEXT("value")}});
span->SetData(TEXT("key"), {{TEXT("data_key2"), 123}});
span->SetData(TEXT("key"), {{TEXT("data_key3"), 123.456f}});
span->SetData(TEXT("key"), {{TEXT("data_key4"), TArray<FSentryVariant>{{123, 456}}}});
span->SetData(TEXT("key"), {{TEXT("data_key5"), TMap<FString, FSentryVariant>{{TEXT("inner_key1"), 123}}}});

span->Finish();
transaction->Finish();
```