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
10 changes: 10 additions & 0 deletions docs/platforms/ruby/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ Provides a lambda or proc that's called with an SDK-specific log object, and can

</SdkOption>

<SdkOption name="std_lib_logger_filter" type="lambda | proc">

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.

<PlatformContent includePath="configuration/std-lib-logger-filter" />

</SdkOption>

<SdkOption name="before_send_check_in" type="lambda | proc">

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.
Expand Down
4 changes: 4 additions & 0 deletions docs/platforms/ruby/logs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ With Sentry Structured Logs, you can send text-based log information from your a

<PlatformContent includePath="logs/integrations" />

## Options

<PlatformContent includePath="logs/options" />

## Default Attributes

<PlatformContent includePath="logs/default-attributes" />
12 changes: 12 additions & 0 deletions platform-includes/configuration/std-lib-logger-filter/ruby.mdx
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 2 additions & 0 deletions platform-includes/logs/integrations/ruby.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Alert level="info" title="Note on structured logging">
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.
</Alert>
Expand Down
11 changes: 11 additions & 0 deletions platform-includes/logs/options/ruby.mdx
Original file line number Diff line number Diff line change
@@ -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.

<PlatformContent includePath="configuration/before-send-log" />

### 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.

<PlatformContent includePath="configuration/std-lib-logger-filter" />