Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception inside traces_sampler proc are not raised #2348

Open
tannakartikey opened this issue Jul 22, 2024 · 2 comments
Open

Exception inside traces_sampler proc are not raised #2348

tannakartikey opened this issue Jul 22, 2024 · 2 comments
Assignees

Comments

@tannakartikey
Copy link

tannakartikey commented Jul 22, 2024

Issue Description

Hello,

Please take a look at the example configuration below for a Rails app. I am raising the exception explicitly inside traces_sampler. However, when the app boots, I don't see any exception raised. All the requests will fail with 500.

I initially got the variable name wrong inside the initializer and it crashed the app. That is more like a real-world scenario why the config should raise or report an exception.

Reproduction Steps

  • Create a Rails app
  • Add the configuration mentioned below at config/initializers/sentry.rb
  • Boot the Rails app
  • Make requests to any routes
  • It should fail with 500 without raising an exception

Expected Behavior

The exception should be raised in the console or reported to Sentry. Right now, there is no way of knowing why my Rails app fails to respond to any requests.

Actual Behavior

The exception is neither raised nor reported on Sentry if it is raised inside traces_sampler proc/lambda.

Ruby Version

3.3.0

SDK Version

5.18.1

Integration and Its Version

rails (8.0.0.alpha e0a9ef1)

Sentry Config

Sentry.init do |config|
  config.dsn = "<DNS>"
  config.breadcrumbs_logger = [ :active_support_logger, :http_logger ]

  # Set traces_sample_rate to 1.0 to capture 100%
  # of transactions for performance monitoring.
  # We recommend adjusting this value in production.
  config.traces_sampler = lambda do |sampling_context|
    rack_env = sampling_context[:env]
    if rack_env && rack_env['PATH_INFO'] =~ /up/
      return 0.0
    else
      return 1.0
    end
  end
end
@sl0thentr0py
Copy link
Member

@tannakartikey we'll try to make this better in some way, it's come up many times before

@tannakartikey
Copy link
Author

tannakartikey commented Jul 22, 2024

Sorry for reporting again. Didn't come up for me when I searched. Thanks. Let me know if I could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants