sentry-ruby icon indicating copy to clipboard operation
sentry-ruby copied to clipboard

Sentry reports traces and errors even if enabled_environments is empty

Open richardboehme opened this issue 8 months ago • 2 comments

Issue Description

From the documentation and the name of the configuration option enabled_environments I was expecting that setting it to an empty array would disable sentry. Instead it gets enabled in all environments.

I worked around this by wrapping the whole Sentry.init block with my enabled-condition. Is this the expected way to disable sentry globally (for example via an environment variable)?

Reproduction Steps

Configure Sentry with the configuration below. Start the Rails server and visit a page.

Expected Behavior

I expected it to not report in any environment.

Actual Behavior

However as the empty array is the default value of the configuration option, it reports in all environments.

Ruby Version

3.4.3

SDK Version

5.23.0

Integration and Its Version

Rails (5.23.0)

Sentry Config

Sentry.init do |config|
  config.dsn = "..."
  config.enabled_environments = []
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]
  config.traces_sample_rate = 1.0
end

richardboehme avatar Apr 25 '25 19:04 richardboehme

right that's kinda confusing, I'll make the default nil instead of an empty array. Thanks for reporting!

sl0thentr0py avatar Apr 28 '25 11:04 sl0thentr0py

will have to do this in the next major since it subtly alters the init api

sl0thentr0py avatar May 05 '25 14:05 sl0thentr0py