Ruby-specific configuration

Follow the standard agent configuration to configure the Ruby agent.

Additionally, there are some configuration guidelines that apply specifically to the Ruby agent:

  • To configure the Ruby agent, place the contrast_security file in the web application's config directory. (You may also place it in the root directory.)

    For sharing a configuration file across multiple applications, you may place the file in /etc/contrast/contrast_security.yaml.

  • If you are using Rails, the Ruby agent functions as a Railtie so no additional configuration is required.

  • If you're using the Sinatra framework, you must configure your application to use the Ruby agent. A simple application configured to work with the Ruby agent looks like the following example:

    require 'sinatra'
    require 'contrast-agent'
    class App < Sinatra::Base
      use Contrast::Agent::Middleware, true
  • The Ruby agent launches an executable on startup that also needs access to the configuration files. Since the service is generally launched by the Ruby agent process, it has access to the same configuration file as the agent. However, if the service is started independently, it will attempt to use the same order of precedence for its configuration file.

    In other words, the service can share the application's configuration file, if (as is usually the case) the service's working directory is also the base directory of the Rails application. Both the agent and the service use the ./config/contrast_security.yaml path.

  • You can further configure the Ruby agent using properties from the YAML template below.