-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Updates the Unity SDK docs with new SetData methods on spans & transa… #13457
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0dc765f
Updates the Unity SDK docs with new SetData methods on spans & transa…
lukemun 2e7c445
Updates the Unity SDK docs with new SetData methods on spans & transa…
lukemun e424a83
Merge branch 'unity-set-data' of https://github.com/lukemun/sentry-do…
lukemun 9e4d262
style(unity): remove trailing spaces
Flash0ver 50844ca
Update platform-includes/performance/improving-data/unity.mdx
lukemun e3141f1
add style to data types and queryable + remove transaction based code…
lukemun 98a833e
Fix conflicts
lukemun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
platform-includes/configuration/data-to-all-spans/unity.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
```csharp | ||
options => | ||
{ | ||
options.SetBeforeSendTransaction(transaction => | ||
{ | ||
// Set the attribute on the root span (transaction's trace context) | ||
transaction.Contexts.Trace.SetData("myAttribute", "myValue"); | ||
|
||
// And on all child spans | ||
foreach (var span in transaction.Spans) | ||
{ | ||
span.SetData("myAttribute", "myValue"); | ||
} | ||
|
||
return transaction; | ||
}); | ||
}; | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## 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 of these types: | ||
|
||
```csharp | ||
var transaction = SentrySdk.StartTransaction("ProcessOrderBatch()", "task"); | ||
lukemun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SentrySdk.ConfigureScope(scope => scope.Transaction = transaction); | ||
transaction.SetData("my-data-attribute-1", "value1"); | ||
transaction.SetData("my-data-attribute-2", 42); | ||
transaction.SetData("my-data-attribute-3", true); | ||
|
||
transaction.SetData("my-data-attribute-4", new[] {"value1", "value2", "value3"}); | ||
transaction.SetData("my-data-attribute-5", new[] {42, 43, 44}); | ||
transaction.SetData("my-data-attribute-6", new[] {true, false, true}); | ||
``` | ||
|
||
### 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 of these types: | ||
|
||
|
||
```csharp | ||
var span = parent.StartChild("task", "operation"); | ||
span.SetData("my-data-attribute-1", "value1"); | ||
span.SetData("my-data-attribute-2", 42); | ||
span.SetData("my-data-attribute-3", true); | ||
|
||
span.SetData("my-data-attribute-4", new[] {"value1", "value2", "value3"}); | ||
span.SetData("my-data-attribute-5", new[] {42, 43, 44}); | ||
span.SetData("my-data-attribute-6", new[] {true, false, true}); | ||
``` | ||
|
||
### Adding Attributes to all Spans and Transactions | ||
|
||
To add an attribute to all spans and transactions, use the `SetBeforeSendTransaction` callback: | ||
|
||
lukemun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<PlatformContent includePath="configuration/data-to-all-spans" /> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.