Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
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" />
18 changes: 18 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,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;
});
};
```
45 changes: 45 additions & 0 deletions platform-includes/performance/improving-data/unity.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## 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
var 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});
```

### 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
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:

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

<PlatformContent includePath="configuration/data-to-all-spans" />
Loading