diff --git a/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx b/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx index 1ccb9b0eb02be4..0d5c2d898d9968 100644 --- a/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx +++ b/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx @@ -15,3 +15,5 @@ To capture transactions and spans customized to your organization's needs, you m + + diff --git a/platform-includes/configuration/data-to-all-spans/unity.mdx b/platform-includes/configuration/data-to-all-spans/unity.mdx new file mode 100644 index 00000000000000..dfd30076584b14 --- /dev/null +++ b/platform-includes/configuration/data-to-all-spans/unity.mdx @@ -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; + }); +}; +``` diff --git a/platform-includes/performance/improving-data/unity.mdx b/platform-includes/performance/improving-data/unity.mdx new file mode 100644 index 00000000000000..ba157059224a34 --- /dev/null +++ b/platform-includes/performance/improving-data/unity.mdx @@ -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"); +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: + +