Add configuration via Ruby file and other improvements
Added
-
Add
config/appsignal.rb
config file support. When aconfig/appsignal.rb
file is present in the app, the Ruby gem will automatically load it whenAppsignal.start
is called.The
config/appsignal.rb
config file is a replacement for theconfig/appsignal.yml
config file. When both files are present, only theconfig/appsignal.rb
config file is loaded when the configuration file is automatically loaded by AppSignal when the configuration file is automatically loaded by AppSignal.Example
config/appsignal.rb
config file:Ruby# config/appsignal.rb Appsignal.configure do |config| config.name = "My app name" end
To configure different option values for environments in the
config/appsignal.rb
config file, use if-statements:Ruby# config/appsignal.rb Appsignal.configure do |config| config.name = "My app name" if config.env == "production" config.ignore_actions << "My production action" end if config.env == "staging" config.ignore_actions << "My staging action" end end
-
Add the
config/appsignal.rb
Ruby config file method to installer,appsignal install
. -
Add
Appsignal.set_empty_params!
helper method. This helper method can be used to unset parameters on a transaction and to prevent the Appsignal instrumentation from adding parameters to a transaction.Example usage:
Rubyclass PaymentsController < ApplicationController def create Appsignal.set_empty_params! # Do things with sensitive parameters end end
When
Appsignal.add_params
is called afterward, the "empty parameters" state is cleared and any AppSignal instrumentation (if called afterward) will also add parameters again.Ruby# Example: Unset parameters when set Appsignal.add_params("abc" => "def") # Parameters: { "abc" => "def" } Appsignal.set_empty_params! # Parameters: {} # Example: When AppSignal instrumentation sets parameters: Appsignal.set_empty_params! # Parameters: {} # Pseudo example code: Appsignal::Instrumentation::SomeLibrary.new.add_params("xyz" => "...") # Parameters: {} # Example: Set parameters after them being unset previously Appsignal.set_empty_params! # Parameters: {} Appsignal.add_params("abc" => "def") # Parameters: { "abc" => "def" }
-
Add
Appsignal.configure
contextenv?
helper method. Check if the loaded environment matches the given environment using the.env?(:env_name)
helper.Example:
RubyAppsignal.configure do |config| # Symbols work as the argument if config.env?(:production) config.ignore_actions << "My production action" end # Strings also work as the argument if config.env?("staging") config.ignore_actions << "My staging action" end end
-
Allow for default attributes to be given when initialising a
Logger
instance:Rubyorder_logger = Appsignal::Logger.new("app", attributes: { order_id: 123 })
All log lines reported by this logger will contain the given attribute. Attributes given when reporting the log line will be merged with the default attributes for the logger, with those in the log line taking priority.
Changed
-
Read the Hanami Action name without metaprogramming in Hanami 2.2 and newer. This makes our instrumentation more stable whenever something changes in future Hanami releases.
-
Ignore these Hanami errors by default:
- Hanami::Router::NotAllowedError (for example: sending a GET request to POST endpoint)
- Hanami::Router::NotFoundError
They are usually errors you don't want to be notified about, so we ignore them by default now.
Customize the
ignore_errors
config option to continue receiving these errors.
Fixed
- Fix request parameter reporting for Hanami 2.2.
View the Ruby gem v4.2.0 changelog for more information.