Skip to content

Commit e900fed

Browse files
lukemunFlash0ver
andauthored
Updates the Unity SDK docs with new SetData methods on spans & transa… (#13457)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR Updates the Unity SDK docs with new SetData methods on spans & transactions SDK changes: getsentry/sentry-dotnet#3936 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --------- Co-authored-by: Stefan Pölz <[email protected]>
1 parent fae2938 commit e900fed

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ To capture transactions and spans customized to your organization's needs, you m
1515
<PlatformContent includePath="performance/add-spans-example" />
1616

1717
<PlatformContent includePath="performance/retrieve-transaction" />
18+
19+
<PlatformContent includePath="performance/improving-data" />
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
```csharp
2+
options =>
3+
{
4+
options.SetBeforeSendTransaction(transaction =>
5+
{
6+
// Set the attribute on the root span (transaction's trace context)
7+
transaction.Contexts.Trace.SetData("myAttribute", "myValue");
8+
9+
// And on all child spans
10+
foreach (var span in transaction.Spans)
11+
{
12+
span.SetData("myAttribute", "myValue");
13+
}
14+
15+
return transaction;
16+
});
17+
};
18+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Improving Data on Transactions and Spans
2+
3+
### Adding Data Attributes to Transactions
4+
5+
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:
6+
7+
```csharp
8+
var transaction = SentrySdk.StartTransaction("ProcessOrderBatch()", "task");
9+
SentrySdk.ConfigureScope(scope => scope.Transaction = transaction);
10+
transaction.SetData("my-data-attribute-1", "value1");
11+
transaction.SetData("my-data-attribute-2", 42);
12+
transaction.SetData("my-data-attribute-3", true);
13+
14+
transaction.SetData("my-data-attribute-4", new[] {"value1", "value2", "value3"});
15+
transaction.SetData("my-data-attribute-5", new[] {42, 43, 44});
16+
transaction.SetData("my-data-attribute-6", new[] {true, false, true});
17+
```
18+
19+
### Adding Data Attributes to Spans
20+
21+
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:
22+
23+
24+
```csharp
25+
var span = parent.StartChild("task", "operation");
26+
span.SetData("my-data-attribute-1", "value1");
27+
span.SetData("my-data-attribute-2", 42);
28+
span.SetData("my-data-attribute-3", true);
29+
30+
span.SetData("my-data-attribute-4", new[] {"value1", "value2", "value3"});
31+
span.SetData("my-data-attribute-5", new[] {42, 43, 44});
32+
span.SetData("my-data-attribute-6", new[] {true, false, true});
33+
```
34+
35+
### Adding Attributes to all Spans and Transactions
36+
37+
To add an attribute to all spans and transactions, use the `SetBeforeSendTransaction` callback:
38+
39+
<PlatformContent includePath="configuration/data-to-all-spans" />

0 commit comments

Comments
 (0)