From e3d66e62fb736def8e4c740dbb05c6ca32800122 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 29 Oct 2026 17:11:29 +0100 Subject: [PATCH] docs(native): fix snippets and stale statements Some native snippets didn't compile and there were a few statements that are no longer valid in the latest 0.17 version. - Pass the missing `options` and `user_data` arguments, drop a trailing comma, use the declared `extra_value`, and bind a transaction with `sentry_set_transaction_object()` instead of `sentry_set_span()`. - Serialize `uint64` as numbers, accept unsigned log attributes, and emit `baggage` alongside `sentry-trace`. - Note that the `native` backend chains signal handlers. --- .../platforms/native/advanced-usage/signal-handling/index.mdx | 2 +- platform-includes/configuration/sample-rate/native.mdx | 2 +- .../distributed-tracing/custom-instrumentation/native.mdx | 2 +- platform-includes/logs/usage/native.mdx | 4 ---- platform-includes/performance/connect-errors-spans/native.mdx | 2 +- .../performance/force-sampling-decision/native.mdx | 2 +- platform-includes/performance/improving-data/native.mdx | 2 +- .../performance/traces-sampler-as-sampler/native.mdx | 2 +- platform-includes/set-extra/native.mdx | 2 +- 9 files changed, 8 insertions(+), 12 deletions(-) diff --git a/docs/platforms/native/advanced-usage/signal-handling/index.mdx b/docs/platforms/native/advanced-usage/signal-handling/index.mdx index f22c56019dafb6..71563660868959 100644 --- a/docs/platforms/native/advanced-usage/signal-handling/index.mdx +++ b/docs/platforms/native/advanced-usage/signal-handling/index.mdx @@ -19,7 +19,7 @@ Sentry's Native SDK comes with its own set of signal handlers. There may be conf * Refrain from registering a conflicting signal handler in your application. * If you have to, register your handler after `sentry_init()` and let it invoke Sentry's handler after it finishes, or you won't get a report. -* If you or one of your dependencies register a handler for the signals listed below _before_ you call `sentry_init()`, Sentry will reinstall that handler as soon as you call `sentry_close()`. Only the `inproc` backend invokes your installed handler at the end of Sentry's handler. +* If you or one of your dependencies register a handler for the signals listed below _before_ you call `sentry_init()`, Sentry will reinstall that handler as soon as you call `sentry_close()`. Only the `inproc` and `native` backends invoke your installed handler at the end of Sentry's handler. * If you want to act on any crash and not consider specific signals, [register an `on_crash()` hook](/platforms/native/configuration/filtering/#using-on_crash) instead of registering a signal handler. ### Signals of Interest diff --git a/platform-includes/configuration/sample-rate/native.mdx b/platform-includes/configuration/sample-rate/native.mdx index dbdad0c8b16b6b..aea527965001b8 100644 --- a/platform-includes/configuration/sample-rate/native.mdx +++ b/platform-includes/configuration/sample-rate/native.mdx @@ -1,5 +1,5 @@ ```c sentry_options_t *options = sentry_options_new(); -sentry_options_set_sample_rate(0.25); +sentry_options_set_sample_rate(options, 0.25); sentry_init(options); ``` diff --git a/platform-includes/distributed-tracing/custom-instrumentation/native.mdx b/platform-includes/distributed-tracing/custom-instrumentation/native.mdx index 6fd44c6d010e8c..00db42225145c2 100644 --- a/platform-includes/distributed-tracing/custom-instrumentation/native.mdx +++ b/platform-includes/distributed-tracing/custom-instrumentation/native.mdx @@ -2,7 +2,7 @@ On this page you will learn how to manually propagate trace information into and To obtain trace headers from a transaction, use `sentry_transaction_iter_headers()`. For a span, use `sentry_span_iter_headers()`. Pass the returned value to the downstream service. If communication happens over HTTP, we recommend you attach all headers to the outgoing HTTP request. -By default, only the `sentry-trace` header is generated. To also generate W3C `traceparent` headers for interoperability with other tracing systems, enable traceparent propagation: +By default, the `sentry-trace` and `baggage` headers are generated. To also generate W3C `traceparent` headers for interoperability with other tracing systems, enable traceparent propagation: ```c sentry_options_set_propagate_traceparent(options, 1); diff --git a/platform-includes/logs/usage/native.mdx b/platform-includes/logs/usage/native.mdx index eb84b088470510..3095380bffdf7b 100644 --- a/platform-includes/logs/usage/native.mdx +++ b/platform-includes/logs/usage/native.mdx @@ -28,10 +28,6 @@ sentry_log_debug("logging with %d custom attributes", attributes, 3); sentry_log_debug("logging with %s custom attributes", sentry_value_new_object(), "no"); ``` - -For now, logs can only take `bool`, `double`, `string` and signed `int` attributes. If you want to send unsigned integer values, you should convert these to strings before creating the attribute. - - These additional attributes take precedence over the default attributes, except for `sentry.message.parameter.X` values; if you pass in a string with format specifiers, these are used for the message parameter values. ```c diff --git a/platform-includes/performance/connect-errors-spans/native.mdx b/platform-includes/performance/connect-errors-spans/native.mdx index fb63d06ee99559..5ef2ab38ad8a0b 100644 --- a/platform-includes/performance/connect-errors-spans/native.mdx +++ b/platform-includes/performance/connect-errors-spans/native.mdx @@ -12,7 +12,7 @@ sentry_transaction_context_t *tx_ctx = sentry_transaction_context_new( sentry_transaction_t *tx = sentry_transaction_start(tx_ctx, sentry_value_new_null()); // Bind the transaction / span to the scope: -sentry_set_span(tx); +sentry_set_transaction_object(tx); // Errors captured after the line above will be linked to the transaction sentry_value_t exc = sentry_value_new_exception( diff --git a/platform-includes/performance/force-sampling-decision/native.mdx b/platform-includes/performance/force-sampling-decision/native.mdx index c64c2c71311352..ef97cb2947a6a1 100644 --- a/platform-includes/performance/force-sampling-decision/native.mdx +++ b/platform-includes/performance/force-sampling-decision/native.mdx @@ -1,7 +1,7 @@ ```c sentry_transaction_context_t *tx_ctx = sentry_transaction_context_new( "transaction", - "op", + "op" ); sentry_transaction_context_set_sampled(tx_ctx, 1); diff --git a/platform-includes/performance/improving-data/native.mdx b/platform-includes/performance/improving-data/native.mdx index 4f274935971b84..6cc7765e4bea1d 100644 --- a/platform-includes/performance/improving-data/native.mdx +++ b/platform-includes/performance/improving-data/native.mdx @@ -3,7 +3,7 @@ You can add Data Attributes to both Spans and Transactions. This data is visible The data must be of type `sentry_value_t`, which can store: * 32-bit signed integers, * 64-bit signed integers, -* 64-bit unsigned integers (due to a current limitation in processing, these will be converted to strings before sending), +* 64-bit unsigned integers, * double-precision floating-points, * null-terminated strings, as well as * lists and string-keyed maps containing `sentry_value_t` entries diff --git a/platform-includes/performance/traces-sampler-as-sampler/native.mdx b/platform-includes/performance/traces-sampler-as-sampler/native.mdx index 41bc9f7bfcf455..760a50fcf6224c 100644 --- a/platform-includes/performance/traces-sampler-as-sampler/native.mdx +++ b/platform-includes/performance/traces-sampler-as-sampler/native.mdx @@ -23,6 +23,6 @@ traces_sampler_callback(const sentry_transaction_context_t *transaction_ctx, } sentry_options_t *options = sentry_options_new(); -sentry_options_set_traces_sampler(options, traces_sampler_callback); +sentry_options_set_traces_sampler(options, traces_sampler_callback, NULL); sentry_init(options); ``` diff --git a/platform-includes/set-extra/native.mdx b/platform-includes/set-extra/native.mdx index ea46fd8bb9ce68..89cf315ccd4230 100644 --- a/platform-includes/set-extra/native.mdx +++ b/platform-includes/set-extra/native.mdx @@ -2,5 +2,5 @@ #include sentry_value_t extra_value = sentry_value_new_string("Mighty Fighter"); -sentry_set_extra("character.name", screen); +sentry_set_extra("character.name", extra_value); ```