Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support disabling the agent per config #1466

Open
slhck opened this issue Jul 3, 2024 · 1 comment
Open

Support disabling the agent per config #1466

slhck opened this issue Jul 3, 2024 · 1 comment

Comments

@slhck
Copy link

slhck commented Jul 3, 2024

Is your feature request related to a problem? Please describe.

I want to disable the APM agent in a particular Rails environment, or via an environment variable setting, to dynamically turn on/off APM reporting. In particular I do not want instrumentation in the Rails test environment.

Describe the solution you'd like

Provide a config option, just like the Node.js version has:

A boolean specifying if the agent should be active or not. If active, the agent will instrument incoming HTTP requests and track errors. Normally you would not want to run the agent in your development or testing environments. If you are using the NODE_ENV environment variable, you can use this to determine the state:

Describe alternatives you've considered

Not loading the Gem, but it is automatically loaded when specified in the Gemfile.

@slhck
Copy link
Author

slhck commented Jul 3, 2024

I was able to work around it by specifying require: false in the Gemfile, and then requiring the Gem only in config/environments/production.rb. That, however, makes it difficult to use ElasticAPM classes throughout the code, since they will have to be wrapped in a if Rails.env.production? statement (otherwise you'll get a class not found error).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant