Mx.Load document
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

2.3.2.1 Ruby

Installing Logger

For the installation steps of Logger, please refer to the following GitHub repository:

GitHub Repository

When Logger is integrated, request logs are sent to Mx.Load when requests are made to the application. Scenarios are generated based on these logs.

  1. Add mxload to the Gemfile of Rails where you want to get the logs.
gem 'mxload', github: 'mxload/mxload_rb' , tag: 'v0.2.3'
  1. Install the gem.
$ bundle install
  1. Add the following two lines to either config/application.rb or config/environments/{RAILS_ENV}.rb.
require "mxload/collector"
config.middleware.insert_before(0, Mxload::Collector)
  • Example of adding to config/application.rb

    ... abbreviated
    
    require "mxload/collector"
    
    ... abbreviated
    
    module TodoApiMock
      class Application < Rails::Application
        ... abbreviated
    
        config.middleware.insert_before(0, Mxload::Collector)
      end
    end
    
  • Example of adding to config/environments/{RAILS_ENV}.rb

    ... abbreviated
    
    require "mxload/collector"
    
    Rails.application.configure do
      ... abbreviated
    
      config.middleware.insert_before(0, Mxload::Collector)
    end
    
  1. Create a config/initializers/mxload.rb file and add the following content.
Mxload.configure do |config|
    config.enable        = true
    config.project_id    = 1
    config.service_key   = 'servicekey'
    config.custom_header = %w[Content-Type]
    config.ignore_paths  = %w[/health]
end

The main configuration parameters are as follows:

  • enable
    • Switches the enable/disable of this gem. Default is false.
  • project_id
    • Sets the id of the created project. project_id can be confirmed from the home or project details.

      project_id

  • service_key
  • custom_header (Optional)
    • Required to record the contents of the header. Example: If you want to include "Content-Type": "application/json", set the value of config.custom_header to %w[Content-Type].
  • ignore_paths (Optional)
    • If the request path is within ignore_paths, ignore sending the request log. Set this when you want to disable paths such as health check paths (/health).

The log parameters sent to Mx.Load are as follows:

  • Method
  • Request path
  • Request body
  • Query parameters
  • Request headers
  • Cookies