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

Add Appsignal.configure besides YAML configuration

Open legendetm opened this issue 5 years ago • 5 comments

Please add initializer support for Appsignal.

Appsignal.configure do |config|
  config.active = ENV['APPSIGNAL_PUSH_API_KEY'].present?
  config.push_api_key = ENV['APPSIGNAL_PUSH_API_KEY']
  config.revision = Rails.root.join('REVISION').exist? ? Rails.root.join('REVISION').read : nil
  config.filter_parameters = Rails.application.config.filter_parameters.map(&:to_s)
  config.request_headers += %w[HTTP_X_CUSTOMER_HEADER]
  confif.ignore_errors += %w[...]
  ...
end
  • Using AppSignal for Ruby gem version 2.10.4
  • In my app using Rails version 6.0.2

legendetm avatar Mar 24 '20 10:03 legendetm

Hi there, it's currently possible to configure AppSignal using Ruby code . Instead of a DSL you are able to pass along a hash to the Appsignal::Config.new method.

Appsignal.config = Appsignal::Config.new(
  Rails.root,
  Rails.env,
  {
    :active => true
  }
)

Do note, that you will not have to do the check for the active conflict option. If the push API key is not present the config will not be active. https://docs.appsignal.com/ruby/configuration/options.html#option-active

tombruijn avatar Mar 24 '20 10:03 tombruijn

With that solution it's unclear for me, if I have to call AppSignal.start manually.

And If I want to extend options += then I have to Appsignal::Config::DEFAULT_CONFIG[:request_headers] + %[HTTP_X_CUSTOMER_HEADER] not config.request_headers += %w[HTTP_X_CUSTOMER_HEADER]

legendetm avatar Mar 24 '20 10:03 legendetm

Yes, you should call Appsignal.start manually, if in a Rails app, in an initializer, so that it overwrites the original config loaded during Rails boot.

I understand the advantages, but we don't have plans to support this DSL at this time. We'll keep the issue open, because I think it's a good idea for in the future.

tombruijn avatar Mar 24 '20 13:03 tombruijn

Do I have to call any other methods manually like integerations (Sidekiq, Redis) or all other things are automatically done?

For example https://docs.appsignal.com/ruby/integrations/rack.html is called start_logger.

It would be nice to have documentation how to the current manual configuration in Rails as well.

legendetm avatar Mar 24 '20 13:03 legendetm

Our integration already calls start logger, it should not be necessary to call it unless you change any logger config options. Since our Railtie already calls it. There should not be any other methods you have to call, the rest is done automatically.

See there is no documentation page for this specific configuration method, I will create an issue on our documentation repository for this.

tombruijn avatar Mar 24 '20 15:03 tombruijn