diff --git a/docs/platforms/ruby/common/configuration/options.mdx b/docs/platforms/ruby/common/configuration/options.mdx index 49955f5533f8f..9dc805338fe14 100644 --- a/docs/platforms/ruby/common/configuration/options.mdx +++ b/docs/platforms/ruby/common/configuration/options.mdx @@ -362,6 +362,16 @@ Provides a lambda or proc that's called with an SDK-specific log object, and can + + +Provides a lambda or proc that's called to filter log messages from Ruby's standard library logger before they are sent to Sentry. This option is only used when the `:logger` patch is enabled via `config.enabled_patches`. + +The callback receives three arguments: `logger` (the logger instance), `message` (the log message string), and `severity` (the log severity level). Return `true` to send the log to Sentry, or `false` to skip it. + + + + + Provides a lambda or proc that's called with a check-in event object, and can return a modified check-in event object, or `nil` to skip reporting the event. diff --git a/docs/platforms/ruby/logs/index.mdx b/docs/platforms/ruby/logs/index.mdx index c3e799b8010af..8726e669e654a 100644 --- a/docs/platforms/ruby/logs/index.mdx +++ b/docs/platforms/ruby/logs/index.mdx @@ -25,6 +25,10 @@ With Sentry Structured Logs, you can send text-based log information from your a +## Options + + + ## Default Attributes diff --git a/platform-includes/configuration/std-lib-logger-filter/ruby.mdx b/platform-includes/configuration/std-lib-logger-filter/ruby.mdx new file mode 100644 index 0000000000000..2b7c33b74a2f4 --- /dev/null +++ b/platform-includes/configuration/std-lib-logger-filter/ruby.mdx @@ -0,0 +1,12 @@ +```ruby +Sentry.init do |config| + config.dsn = "___PUBLIC_DSN___" + config.enable_logs = true + config.enabled_patches << :logger + + # Only send ERROR and FATAL logs to Sentry + config.std_lib_logger_filter = proc do |logger, message, severity| + [:error, :fatal].include?(severity) + end +end +``` diff --git a/platform-includes/logs/integrations/ruby.mdx b/platform-includes/logs/integrations/ruby.mdx index e4b96cb6d894b..e2e34d56dd8b5 100644 --- a/platform-includes/logs/integrations/ruby.mdx +++ b/platform-includes/logs/integrations/ruby.mdx @@ -18,6 +18,8 @@ logger.info("Hello from stdlib logger") logger.error("Hello from stdlib logger") ``` +You can filter which logs are sent to Sentry using the [`std_lib_logger_filter`](/platforms/ruby/configuration/options/#std-lib-logger-filter) configuration option. + Ruby's stdlib logger does not support structured logging, that's why logs are sent to Sentry as plain messages with default attributes added automatically by the SDK. diff --git a/platform-includes/logs/options/ruby.mdx b/platform-includes/logs/options/ruby.mdx new file mode 100644 index 0000000000000..5d3a3b2082b68 --- /dev/null +++ b/platform-includes/logs/options/ruby.mdx @@ -0,0 +1,11 @@ +### before_send_log + +To filter logs before they are sent to Sentry, use the `before_send_log` callback. Return `nil` to skip a log, or return the log object to send it. + + + +### std_lib_logger_filter + +When using the `:logger` patch for Ruby's standard library logger, you can filter log messages using `std_lib_logger_filter`. The callback receives the logger instance, message, and severity level. Return `true` to send the log, or `false` to skip it. + +