Skip to content

Scout Agent Running in Console in Rails 7 #481

@mabrikan

Description

@mabrikan

We faced an issue in which scout agent will start and worker thread will get initialized when running bundle exec rails console.

I inspected the code that does the checks and I believe that method interactive? in lib/scout_apm/environment.rb is the one doing so

    # If both stdin & stdout are interactive and the Rails::Console constant is defined
    def interactive?
      defined?(::Rails::Console) && $stdout.isatty && $stdin.isatty
    end

I did some debugging and discovered that in later versions of rails (6 or higher) where spring is used to load the app, ::Rails::Console can become undefined. Of course this causes the method above to return false, hence the agent gets initialized.

I searched for a fix and stumbled upon this thread in another project, but discussing the same issue.

A workaround is to disable spring using export DISABLE_SPRING=true before running rails console

I just wanted to share this info, also maybe if there is a way to detect if spring is working and add a condition to the method above.

Version info:
ruby '3.2.1'
'rails', '~> 7.0.4.3'
'scout_apm', ''5.3.5'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Info/ReproThis issue needs more clarification or a minimal reproducible case.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions