From aaa13f0d61069012e04fe55560d481c148a296e8 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Wed, 29 Jul 2026 14:41:57 +0200 Subject: [PATCH 1/3] docs(rust): logs and metrics features enabled by default Correct the Rust SDK docs to reflect that the `logs` and `metrics` crate features are now enabled by default. Also, correct any stale references that imply that either of these options need to be enabled at runtime. Resolves #18863 Resolves [RUST-271](https://linear.app/getsentry/issue/RUST-271/document-new-logsmetrics-feature-flag-defaults) --- .../rust/common/configuration/options.mdx | 4 ++-- docs/platforms/rust/common/logs/index.mdx | 24 +++++++------------ docs/platforms/rust/guides/tracing/index.mdx | 12 +++------- platform-includes/metrics/options/rust.mdx | 2 +- .../metrics/requirements/rust.mdx | 10 ++------ 5 files changed, 16 insertions(+), 36 deletions(-) diff --git a/docs/platforms/rust/common/configuration/options.mdx b/docs/platforms/rust/common/configuration/options.mdx index a745e38e15aba..e06e95c8f7022 100644 --- a/docs/platforms/rust/common/configuration/options.mdx +++ b/docs/platforms/rust/common/configuration/options.mdx @@ -198,12 +198,12 @@ By default, the SDK uses a transport based on the `reqwest` crate running on a b ## Logging Options -The following features and options are only available when the `logs` feature of the `sentry` crate is enabled. This is not a default feature. - Determines whether captured structured logs should be sent to Sentry. +Sending logs requires Sentry to be compiled with the `logs` feature. As the `logs` feature is included in the default feature set, you only explicitly need to enable `logs` when compiling without default features. + diff --git a/docs/platforms/rust/common/logs/index.mdx b/docs/platforms/rust/common/logs/index.mdx index 3d6337a2d1510..81a09d6e3a237 100644 --- a/docs/platforms/rust/common/logs/index.mdx +++ b/docs/platforms/rust/common/logs/index.mdx @@ -11,22 +11,16 @@ With Sentry Structured Logs, you can send text-based log information from your a ## Requirements Logs in Rust are supported in Sentry Rust SDK version `0.42.0` and above. -Additionally, the `logs` feature flag needs to be enabled. - -```toml {filename:Cargo.toml} -[dependencies] -sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = ["logs"] } -``` ## Setup -To enable logging, just add the `sentry` dependency with the `logs` feature flag. -This will set `enable_logs: true` by default in your `sentry::ClientOptions`. -You can opt-out from sending logs even while using the `logs` feature flag by explicitly initializing the SDK with `enable_logs: false`. +Logs are enabled by default in the Rust SDK. + +If you compile `sentry` without default features, you must explicitly enable the `logs` feature flag to send logs. ## Usage -Once the feature is enabled and the SDK is initialized, you can send logs by using the logging macros. +Once the SDK is initialized, you can send logs by using the logging macros. The `sentry` crate exposes macros that support six different log levels: `logger_trace`, `logger_debug`, `logger_info`, `logger_warn`, `logger_error` and `logger_fatal`. The macros support logging a simple message, or a message with parameters, with `format` syntax: @@ -68,7 +62,7 @@ To use the `tracing` integration with logs, add the necessary dependencies to yo ```toml {filename:Cargo.toml} [dependencies] -sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = ["tracing", "logs"] } +sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = ["tracing"] } tracing = "0.1.41" tracing-subscriber = "0.3.19" ``` @@ -111,7 +105,7 @@ The fields of `tracing` events are automatically captured as attributes in Sentr By default, `tracing` events at or above info level are captured as Sentry logs. This behavior can be customized by applying a custom `event_filter` when creating the layer. -The following snippet shows the default `event_filter` that's applied when using the `sentry` crate with the `logs` feature flag. +The following snippet shows the default `event_filter`: ```rust use sentry::integrations::tracing::EventFilter; @@ -133,7 +127,7 @@ To use the `log` integration with logs, add the necessary dependencies to your ` ```toml {filename:Cargo.toml} [dependencies] -sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = ["log", "logs"] } +sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = ["log"] } log = "0.4" # optional: use any log implementation you prefer env_logger = "0.11" @@ -149,8 +143,7 @@ fn main() { let _guard = sentry::init( sentry::ClientOptions::new() .dsn("___PUBLIC_DSN___") - .maybe_release(sentry::release_name!()) - .enable_logs(true), + .maybe_release(sentry::release_name!()), ); let logger = sentry::integrations::log::SentryLogger::with_dest( @@ -181,7 +174,6 @@ let _guard = sentry::init( sentry::ClientOptions::new() .dsn("___PUBLIC_DSN___") .maybe_release(sentry::release_name!()) - .enable_logs(true) .before_send_log(|log| { // filter out all trace level logs if log.level == sentry::protocol::LogLevel::Trace { diff --git a/docs/platforms/rust/guides/tracing/index.mdx b/docs/platforms/rust/guides/tracing/index.mdx index f4813fea2e892..f2ab48c5c809e 100644 --- a/docs/platforms/rust/guides/tracing/index.mdx +++ b/docs/platforms/rust/guides/tracing/index.mdx @@ -22,10 +22,7 @@ To add Sentry with the `tracing` integration to your Rust project, add the neces tracing = "0.1.41" tracing-subscriber = "0.3.19" sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = [ - "tracing", - # ___PRODUCT_OPTION_START___ logs - "logs", - # ___PRODUCT_OPTION_END___ logs + "tracing" ] } tokio = { version = "1.45.0", features = ["full"] } ``` @@ -53,9 +50,6 @@ fn main() { // Capture all traces and spans. Set to a lower value in production .traces_sample_rate(1.0) # ___PRODUCT_OPTION_END___ performance - # ___PRODUCT_OPTION_START___ logs - .enable_logs(true), - # ___PRODUCT_OPTION_END___ logs ); // Register the Sentry tracing layer @@ -88,10 +82,10 @@ async fn fail() { By default, error-level events from `tracing` are captured as Sentry events, while events at or above info level are added to the current scope as breadcrumbs. -Additionally, if the `logs` feature flag of the `sentry` crate is enabled and the SDK is initialized with `enable_logs: true`, then events from `tracing` at info level or above are also captured as [structured logs](https://docs.sentry.io/product/logs/). +Additionally, the SDK captures [logs](https://docs.sentry.io/product/logs/ for `tracing` events at the info level or above, unless logs were disabled when initializing the SDK. This behavior can be customized by applying a custom `event_filter` when creating the layer. -The following snippet shows the default `event_filter` that's applied when using the `sentry` crate with the `logs` feature flag. +The following snippet shows the default `event_filter` that's applied when using the `sentry` crate with the `tracing` feature flag. ```rust use sentry::integrations::tracing::EventFilter; diff --git a/platform-includes/metrics/options/rust.mdx b/platform-includes/metrics/options/rust.mdx index f53778be8bdc3..2df4e14593bb5 100644 --- a/platform-includes/metrics/options/rust.mdx +++ b/platform-includes/metrics/options/rust.mdx @@ -20,7 +20,7 @@ let _guard = sentry::init( ### Disabling Metrics -Metrics are enabled by default when the `sentry` crate is compiled with the `metrics` feature. To stop sending metrics, call [`.enable_metrics(false)`](https://docs.rs/sentry/latest/sentry/struct.ClientOptions.html#method.enable_metrics) on [`ClientOptions`](https://docs.rs/sentry/latest/sentry/struct.ClientOptions.html). +To stop sending metrics, call [`.enable_metrics(false)`](https://docs.rs/sentry/latest/sentry/struct.ClientOptions.html#method.enable_metrics) on [`ClientOptions`](https://docs.rs/sentry/latest/sentry/struct.ClientOptions.html) when initialzing the SDK. ```rust {filename:main.rs} let _guard = sentry::init( diff --git a/platform-includes/metrics/requirements/rust.mdx b/platform-includes/metrics/requirements/rust.mdx index 2030cd506c492..0a5c3f8845e3c 100644 --- a/platform-includes/metrics/requirements/rust.mdx +++ b/platform-includes/metrics/requirements/rust.mdx @@ -1,8 +1,2 @@ -Metrics for Rust are supported in Sentry Rust SDK version `0.48.0` or later when compiled with the `metrics` feature. - -```toml {filename:Cargo.toml} -[dependencies] -sentry = { version = "{{@inject packages.version('sentry.rust') }}", features = ["metrics"] } -``` - -Metrics are enabled by default. +Metrics for Rust are supported in Sentry Rust SDK version `0.48.0` or later. +The `metrics` feature is enabled by default in the top-level `sentry` crate, and metrics are enabled by default at runtime. From 54c407f8b0936065cc9e61861b7325785bbe4b94 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Wed, 29 Jul 2026 15:15:01 +0200 Subject: [PATCH 2/3] fixup! docs(rust): logs and metrics features enabled by default --- docs/platforms/rust/guides/tracing/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/rust/guides/tracing/index.mdx b/docs/platforms/rust/guides/tracing/index.mdx index f2ab48c5c809e..b560b48192e6e 100644 --- a/docs/platforms/rust/guides/tracing/index.mdx +++ b/docs/platforms/rust/guides/tracing/index.mdx @@ -82,7 +82,7 @@ async fn fail() { By default, error-level events from `tracing` are captured as Sentry events, while events at or above info level are added to the current scope as breadcrumbs. -Additionally, the SDK captures [logs](https://docs.sentry.io/product/logs/ for `tracing` events at the info level or above, unless logs were disabled when initializing the SDK. +Additionally, the SDK captures [logs](https://docs.sentry.io/product/logs/) for `tracing` events at the info level or above, unless logs were disabled when initializing the SDK. This behavior can be customized by applying a custom `event_filter` when creating the layer. The following snippet shows the default `event_filter` that's applied when using the `sentry` crate with the `tracing` feature flag. From 0e83cb73ef7ee9cd6db7408e8d1adde981cfca71 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Thu, 30 Jul 2026 15:00:41 +0200 Subject: [PATCH 3/3] fixup! fixup! docs(rust): logs and metrics features enabled by default --- docs/platforms/rust/common/logs/index.mdx | 3 +-- platform-includes/metrics/options/rust.mdx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/platforms/rust/common/logs/index.mdx b/docs/platforms/rust/common/logs/index.mdx index 81a09d6e3a237..700e3f79422a7 100644 --- a/docs/platforms/rust/common/logs/index.mdx +++ b/docs/platforms/rust/common/logs/index.mdx @@ -78,8 +78,7 @@ fn main() { let _guard = sentry::init( sentry::ClientOptions::new() .dsn("___PUBLIC_DSN___") - .maybe_release(sentry::release_name!()) - .enable_logs(true), + .maybe_release(sentry::release_name!()), ); tracing_subscriber::registry() diff --git a/platform-includes/metrics/options/rust.mdx b/platform-includes/metrics/options/rust.mdx index 2df4e14593bb5..78a4bbb373060 100644 --- a/platform-includes/metrics/options/rust.mdx +++ b/platform-includes/metrics/options/rust.mdx @@ -20,7 +20,7 @@ let _guard = sentry::init( ### Disabling Metrics -To stop sending metrics, call [`.enable_metrics(false)`](https://docs.rs/sentry/latest/sentry/struct.ClientOptions.html#method.enable_metrics) on [`ClientOptions`](https://docs.rs/sentry/latest/sentry/struct.ClientOptions.html) when initialzing the SDK. +To stop sending metrics, call [`.enable_metrics(false)`](https://docs.rs/sentry/latest/sentry/struct.ClientOptions.html#method.enable_metrics) on [`ClientOptions`](https://docs.rs/sentry/latest/sentry/struct.ClientOptions.html) when initializing the SDK. ```rust {filename:main.rs} let _guard = sentry::init(