From 2098592484dfe97708e6a9fd8cfd37b26cd6e9ff Mon Sep 17 00:00:00 2001 From: JoshuaMoelans <60878493+JoshuaMoelans@users.noreply.github.com> Date: Mon, 27 Jan 2025 11:51:05 +0100 Subject: [PATCH] cherry pick changes from old PR --- .../custom-instrumentation.mdx | 2 + .../performance/improving-data/native.mdx | 81 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 platform-includes/performance/improving-data/native.mdx diff --git a/docs/platforms/native/common/tracing/instrumentation/custom-instrumentation.mdx b/docs/platforms/native/common/tracing/instrumentation/custom-instrumentation.mdx index 15cfe5aa9f1dfd..1a9305e2ba8227 100644 --- a/docs/platforms/native/common/tracing/instrumentation/custom-instrumentation.mdx +++ b/docs/platforms/native/common/tracing/instrumentation/custom-instrumentation.mdx @@ -38,6 +38,8 @@ When using these functions, you should ensure that the provided timestamps are c + + ## Distributed Tracing In order to use distributed tracing with the Native SDK, follow the custom instrumentation steps. diff --git a/platform-includes/performance/improving-data/native.mdx b/platform-includes/performance/improving-data/native.mdx new file mode 100644 index 00000000000000..cb1b96e225dde1 --- /dev/null +++ b/platform-includes/performance/improving-data/native.mdx @@ -0,0 +1,81 @@ +## Improving Data on Transactions and Spans +You can add Data Attributes to both Spans and Transactions. This data is visible in the trace explorer in Sentry. +The data must be of type `sentry_value_t`, which can store: +* 32-bit signed integers, +* double-precision floating-points, +* null-terminated strings, as well as +* lists and string-keyed maps containing `sentry_value_t` entries + +### Adding Data Attributes to Transactions + +You can add data attributes to your transactions using the following API: + +```c +sentry_transaction_context_t *tx_ctx = + sentry_transaction_context_new("processOrderBatch()", "task"); +sentry_transaction_t *tx = + sentry_transaction_start(tx_ctx, sentry_value_new_null()); + +sentry_transaction_set_data(tx, "my-data-attribute-1", + sentry_value_new_string("value1")); +sentry_transaction_set_data(tx, "my-data-attribute-2", + sentry_value_new_int32(42)); +sentry_transaction_set_data(tx, "my-data-attribute-3", + sentry_value_new_double(3.14)); +sentry_transaction_set_data(tx, "my-data-attribute-4", + sentry_value_new_bool(true)); + +sentry_value_t value_list = sentry_value_new_list(); +sentry_value_append(value_list, sentry_value_new_string("value1")); +sentry_value_append(value_list, sentry_value_new_int32(42)); +sentry_value_append(value_list, sentry_value_new_double(3.14)); +sentry_value_append(value_list, sentry_value_new_bool(true)); + +sentry_transaction_set_data(tx, "my-data-attribute-5", value_list); + +sentry_value_t value_object = sentry_value_new_object(); +sentry_value_set_by_key(value_object, "key_1", sentry_value_new_string("value1")); +sentry_value_set_by_key(value_object, "key_2", sentry_value_new_int32(42)); +sentry_value_set_by_key(value_object, "key_3", sentry_value_new_double(3.14)); +sentry_value_set_by_key(value_object, "key_4", sentry_value_new_bool(true)); + +sentry_transaction_set_data(tx, "my-data-attribute-6", value_object); +``` + +### Adding Data Attributes to Spans + +You can add data attributes to your spans using the following API: + +```c +sentry_transaction_context_t *tx_ctx = + sentry_transaction_context_new("processOrderBatch()", "task"); +sentry_transaction_t *tx = + sentry_transaction_start(tx_ctx, sentry_value_new_null()); +sentry_span_t *span = + sentry_transaction_start_child(tx, "task", "operation"); + +sentry_span_set_data(span, "my-data-attribute-1", + sentry_value_new_string("value1")); +sentry_span_set_data(span, "my-data-attribute-2", + sentry_value_new_int32(42)); +sentry_span_set_data(span, "my-data-attribute-3", + sentry_value_new_double(3.14)); +sentry_span_set_data(span, "my-data-attribute-4", + sentry_value_new_bool(true)); + +sentry_value_t value_list = sentry_value_new_list(); +sentry_value_append(value_list, sentry_value_new_string("value1")); +sentry_value_append(value_list, sentry_value_new_int32(42)); +sentry_value_append(value_list, sentry_value_new_double(3.14)); +sentry_value_append(value_list, sentry_value_new_bool(true)); + +sentry_span_set_data(span, "my-data-attribute-5", value_list); + +sentry_value_t value_object = sentry_value_new_object(); +sentry_value_set_by_key(value_object, "key_1", sentry_value_new_string("value1")); +sentry_value_set_by_key(value_object, "key_2", sentry_value_new_int32(42)); +sentry_value_set_by_key(value_object, "key_3", sentry_value_new_double(3.14)); +sentry_value_set_by_key(value_object, "key_4", sentry_value_new_bool(true)); + +sentry_span_set_data(span, "my-data-attribute-6", value_object); +```