-
Notifications
You must be signed in to change notification settings - Fork 174
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
Difficulty configuring Bugsnag in Rails before it configures itself #391
Comments
So at the moment there isn't a way to do that in several of supported framework. We're automatically requiring the framework integrations which can trigger off configuration options, such as the While there's no way to disable this at the moment, if this is requested it's something we could look into adding in the future. |
@csuhta Can you provide some examples of the kinds of configuration you'd like to change up front? Perhaps there are specific options we could provide or options we can better surface in the documentation. |
@kattrali For our use case: We have a lot of nighty/hourly sync processes and rake tasks. I would like to override the Bugsnag logger object to point to a custom logger and sometimes also want to completely silence the gem, including the |
Gotcha. That makes a lot of sense. We could potentially support an environment variable (e.g. |
@kattrali That would be perfect. I'm happy to configure the gem myself if I can cleanly wrest automatic behavior away from it. |
We're currently noticing similar behavior where the Railtie |
@cookrn We're having the same problem. |
@cookrn @RobertoSchneiders my fix for now is to just set the key in advance as the environment variable bugsnag-ruby/lib/bugsnag/configuration.rb Line 76 in 7336834
|
@kattrali why did this issue get closed? |
@jfelchner It's now possible to set |
@csuhta I don't want to disable autoconfiguration, I just don't want a warning telling me that my API key is not valid when I'm setting my API key in the initializer. |
Can we reopen this issue until this gets fixed? |
I've reopened this one as a matter of course, but it looks to me like the issue is solved and you are experiencing something else @jfelchner. You are seeing bugsnag log that the api key is invalid, but it's correct? That would be a different issue worth raising a separate issue for to make sure it doesnt get lost. If |
@snmaynard it's basically the same issue as this whereby Bugsnag is initializing itself before the point in the Rails boot process where Rails reads the And in response to your question, yes, the API key is correct. It's not that Bugsnag doesn't eventually find the API key (it does), but prior to that, it logs that the API key is invalid. |
Also for some more clarification, if I move the The reason you're probably not seeing this is because you're probably setting your |
I'm also experiencing problems configuring Bugsnag in a Rails initializer. Setting the API key there does nothing. It has to be done earlier. The opening example is misleading: # config/initializers/bugsnag.rb
Bugsnag.configure do |config|
config.api_key = ENV.fetch("BUGSNAG_API_KEY")
...
end The API key is not being set here. Rather it's using ENV["BUGSNAG_API_KEY"] directly when Bugsnag is loaded. I'm currently using Rails 5.2 RC2 with the new Credentials feature (I'm moving away from using ENV variables for atomic deploys). I tried the following: # config/initializers/bugsnag.rb
Bugsnag.configure do |config|
config.api_key = Rails.application.credentials.bugsnag_api_key
end This unfortunately does not work because the initializer is executed too late. I get the following warning with this configuration: If I move the same configuration to # config/application.rb
Bugsnag.configure do |config|
config.api_key = Rails.application.credentials.bugsnag_api_key
end The rest of the configuration can be set in |
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
When not initializing using the BUGSNAG_API_KEY environment variable, the first time the Railtie integration is loaded, no API key is available. At the bottom of the configure method, a warning is emitted stating that no API key has been set, though this may not be true after config/initializers/bugsnag.rb runs. This is the behavior being observed in #391, causing concern that bugsnag is not working correctly when in fact the log message is premature. This change allows for Bugsnag.configure to be called without validating the key, allowing the Railtie integration to add an additional check once Rails initialization is complete. Fixes #391
As per my comment here: #438 (comment) can we reopen this until it is adequately fixed? |
@jfelchner a change has been made into how the API key validity is logged, which will be released shortly. This will fix the issues as noted here. |
Here's an example initializer in Rails:
The Bugsnag ready message gets logged before this initializer runs:
I want to change the Bugsnag logger and/or explicitly configure Bugsnag myself. I do not want the gem to try to automatically detect its own configuration. What is the correct way to do this in Rails and other Ruby environments when using Gemfiles/Rubygems to load this gem?
The text was updated successfully, but these errors were encountered: