Install the Ruby microagent

  1. Review Ruby microagent compatibility to confirm that the Sqreen Microagent for Ruby is compatible with your application.
  2. Sign up to create your Sqreen account.
  3. Fetch your organization token. From the Sqreen Dashboard, access Account Settings > Environments & Tokens. Your token begins with env_org_. Take note of the token.
  4. In your application root directory, add the microagent gem to your Gemfile.
    echo "gem 'sqreen', '>= 1.16'" >> Gemfile
    
  5. From Terminal, install the gem in your application root directory, and set the Sqreen token and application name. When using Rails, the application name derives from Rails's application class name.
    # Install the Sqreen gem from your application directory
    bundle install
    
    # Set the Sqreen token and the application name
    cat > config/sqreen.yml <<EOF
    app_name: "YOUR_APPLICATION_NAME"
    token: "SQREEN_TOKEN"
    EOF
    

The Sqreen Microagent for Ruby is also available in the RubyGems repository.

Install in multiple environments

Typically, you install the Sqreen microagent in your production environment, but you can install it in multiple environments. Use a different name and token for each environment such as production, staging, and development.

  1. From the Sqreen Dashboard, navigate to Account Settings > Environments & Tokens, and Add a new Environment.
  2. Sqreen automatically creates a new token and associates it with the new environment. Take note of the new token.
  3. Set up your application name and SQREEN_TOKEN and include the environment name.
# Set the Sqreen token and the app name, including the environment
cat > config/sqreen.yml <<EOF
app_name: "foobar (production)"
token: "SQREEN_TOKEN"
EOF

Install using Bundler with a Sinatra app

  1. Follow the steps above to install the microagent.
  2. In the Gemfile, require the Sqreen gem in your application code after Sinatra.
    require 'sinatra'
    require 'sqreen'
    

Install without C++11 compiler

Some environments lack a C++11-compliant compiler (GCC >= 4.8 or clang >= 3.5) which can complicate an installation. The following describe two situations that lack a C++-compliant compiler, and how to mitigate them.

  • Stripped down Docker containers: Install g++ or clang before running bundle install or gem install. You can remove the C++ compiler afterward, but you must keep the C++ runtime library (usually libstdc++).

  • Old operating system distributions, such as Ubuntu Precise Pangolin: Install a new compiler from separate package repositories.

Install on Travis Precise

To install Sqreen on Travis Precise, install GCC 4.8 by adding the following to the .travis.yml file:

addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-4.8
env:
  - CXX=g++-4.8

Uninstall

To uninstall the Ruby microagent, remove the sqreen gem from your Gemfile.