Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -38,6 +38,8 @@ When using these functions, you should ensure that the provided timestamps are c

<PlatformContent includePath="performance/connect-errors-spans" />

<PlatformContent includePath="performance/improving-data" />

## Distributed Tracing

In order to use distributed tracing with the Native SDK, follow the <PlatformLink to="/tracing/trace-propagation/custom-instrumentation/">custom instrumentation</PlatformLink> steps.
81 changes: 81 additions & 0 deletions platform-includes/performance/improving-data/native.mdx
Original file line number Diff line number Diff line change
@@ -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);
```
Loading