Skip to content
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 @@ -15,3 +15,5 @@ To capture transactions and spans customized to your organization's needs, you m
<PlatformContent includePath="performance/add-spans-example" />

<PlatformContent includePath="performance/retrieve-transaction" />

<PlatformContent includePath="performance/improving-data" />
22 changes: 22 additions & 0 deletions platform-includes/configuration/data-to-all-spans/unity.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```csharp
SentrySdk.Init(options =>
{
options.SetBeforeSendTransaction(transaction =>
{
// Set the attribute on the root span
if (transaction.Contexts.Trace == null)
{
transaction.Contexts.Trace = new SpanContext();
}
transaction.Contexts.Trace.SetData("myAttribute", "myValue");

// And on all child spans
foreach (var span in transaction.Spans)
{
span.SetData("myAttribute", "myValue");
}

return transaction;
});
});
```
47 changes: 47 additions & 0 deletions platform-includes/performance/improving-data/unity.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## Improving Data on Transactions and Spans

### Adding Data Attributes to Transactions

You can add data attributes to your transactions. This data is visible in the trace explorer in Sentry. Data attributes can be of type `string`, `number` or `boolean`, as well as arrays of these types:

```csharp
ITransaction transaction = SentrySdk.StartTransaction("processOrderBatch()", "task");
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});
```

<Alert level="info">
The <code>SetExtra</code> method is still supported but has been deprecated in favor of <code>SetData</code>.
</Alert>

### Adding Data Attributes to Spans

You can add data attributes to your spans. This data is visible in the trace explorer in Sentry. Data attributes can be of type `string`, `number` or `boolean`, as well as arrays of these types:

```csharp
ISpan 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 `BeforeSendTransaction` callback:

```csharp
options.SetBeforeSendTransaction(transaction =>
{
transaction.SetData("environment-data", GetEnvironmentData());
return transaction;
});
```
Loading