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