From 0dc765faf079e2de7854a9ea04a854ff52e941d9 Mon Sep 17 00:00:00 2001 From: lukemun Date: Mon, 21 Apr 2025 10:49:20 -0400 Subject: [PATCH 1/5] Updates the Unity SDK docs with new SetData methods on spans & transactions SDK changes: https://github.com/getsentry/sentry-dotnet/pull/3936 --- .../custom-instrumentation.mdx | 2 + .../configuration/data-to-all-spans/unity.mdx | 22 +++++++++ .../performance/improving-data/unity.mdx | 47 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 platform-includes/configuration/data-to-all-spans/unity.mdx create mode 100644 platform-includes/performance/improving-data/unity.mdx diff --git a/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx b/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx index 1ccb9b0eb02be..e3396b5d5ff64 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 0000000000000..83bbe73bf0046 --- /dev/null +++ b/platform-includes/configuration/data-to-all-spans/unity.mdx @@ -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; + }); +}); +``` diff --git a/platform-includes/performance/improving-data/unity.mdx b/platform-includes/performance/improving-data/unity.mdx new file mode 100644 index 0000000000000..7089bb02082ce --- /dev/null +++ b/platform-includes/performance/improving-data/unity.mdx @@ -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}); +``` + + +The SetExtra method is still supported but has been deprecated in favor of SetData. + + +### 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; +}); +``` From 2e7c445dae5dbeacf4f349b7b29c39ce414ff7d4 Mon Sep 17 00:00:00 2001 From: lukemun Date: Mon, 21 Apr 2025 10:49:20 -0400 Subject: [PATCH 2/5] Updates the Unity SDK docs with new SetData methods on spans & transactions SDK changes: https://github.com/getsentry/sentry-dotnet/pull/3936 --- .../custom-instrumentation.mdx | 2 + .../configuration/data-to-all-spans/unity.mdx | 18 ++++++++ .../performance/improving-data/unity.mdx | 45 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 platform-includes/configuration/data-to-all-spans/unity.mdx create mode 100644 platform-includes/performance/improving-data/unity.mdx diff --git a/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx b/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx index 1ccb9b0eb02be..e3396b5d5ff64 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 0000000000000..505fb59e24801 --- /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 0000000000000..175fef1d16c62 --- /dev/null +++ b/platform-includes/performance/improving-data/unity.mdx @@ -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; +}); +``` + + From 9e4d262837510eb108f12d2db600452a447ac468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20P=C3=B6lz?= <38893694+Flash0ver@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:24:03 +0200 Subject: [PATCH 3/5] style(unity): remove trailing spaces trying to push changes to see whether a preview deployment kicks off --- .../unity/tracing/instrumentation/custom-instrumentation.mdx | 2 +- platform-includes/configuration/data-to-all-spans/unity.mdx | 4 ++-- platform-includes/performance/improving-data/unity.mdx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx b/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx index e3396b5d5ff64..0d5c2d898d996 100644 --- a/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx +++ b/docs/platforms/unity/tracing/instrumentation/custom-instrumentation.mdx @@ -16,4 +16,4 @@ 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 index 505fb59e24801..dfd30076584b1 100644 --- a/platform-includes/configuration/data-to-all-spans/unity.mdx +++ b/platform-includes/configuration/data-to-all-spans/unity.mdx @@ -2,7 +2,7 @@ options => { options.SetBeforeSendTransaction(transaction => - { + { // Set the attribute on the root span (transaction's trace context) transaction.Contexts.Trace.SetData("myAttribute", "myValue"); @@ -15,4 +15,4 @@ options => return transaction; }); }; -``` +``` diff --git a/platform-includes/performance/improving-data/unity.mdx b/platform-includes/performance/improving-data/unity.mdx index 175fef1d16c62..6b24658c23c6d 100644 --- a/platform-includes/performance/improving-data/unity.mdx +++ b/platform-includes/performance/improving-data/unity.mdx @@ -40,6 +40,6 @@ options.SetBeforeSendTransaction(transaction => transaction.SetData("environment-data", GetEnvironmentData()); return transaction; }); -``` +``` From 50844ca43090447ba63ef972c6420a5acedbcf80 Mon Sep 17 00:00:00 2001 From: Luke Munro Date: Tue, 29 Apr 2025 12:45:21 -0400 Subject: [PATCH 4/5] Update platform-includes/performance/improving-data/unity.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com> --- platform-includes/performance/improving-data/unity.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/platform-includes/performance/improving-data/unity.mdx b/platform-includes/performance/improving-data/unity.mdx index 6b24658c23c6d..b1f6f22e94e24 100644 --- a/platform-includes/performance/improving-data/unity.mdx +++ b/platform-includes/performance/improving-data/unity.mdx @@ -6,6 +6,7 @@ You can add data attributes to your transactions. This data is visible in the tr ```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); From e3141f17e2f20e1c80c9679fcaa09a0db9234f09 Mon Sep 17 00:00:00 2001 From: lukemun Date: Mon, 5 May 2025 19:11:17 -0400 Subject: [PATCH 5/5] add style to data types and queryable + remove transaction based code sample in favor of trace --- .../performance/improving-data/unity.mdx | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/platform-includes/performance/improving-data/unity.mdx b/platform-includes/performance/improving-data/unity.mdx index 175fef1d16c62..4e8f49fbb479d 100644 --- a/platform-includes/performance/improving-data/unity.mdx +++ b/platform-includes/performance/improving-data/unity.mdx @@ -2,7 +2,7 @@ ### 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: +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"); @@ -17,7 +17,8 @@ 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: +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"); @@ -34,12 +35,4 @@ span.SetData("my-data-attribute-6", new[] {true, false, true}); To add an attribute to all spans and transactions, use the `SetBeforeSendTransaction` callback: -```csharp -options.SetBeforeSendTransaction(transaction => -{ - transaction.SetData("environment-data", GetEnvironmentData()); - return transaction; -}); -``` -