-
Notifications
You must be signed in to change notification settings - Fork 381
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
Avoid diagnostics on rails console #3079
base: master
Are you sure you want to change the base?
Conversation
Currently I get a huge DATADOG CONFIGURATION payload output when starting a rails console. The `Rails::Console` constant is only loaded when the `rails console` command is run: https://github.com/rails/rails/blob/main/railties/lib/rails/commands/console/console_command.rb It's a semi-conventional way to detect if we're running in a rails console.
👋 @sj26, this is a good call! We actually introduced specific code recently to detect just this kind of scenario, as we needed this detection logic elsewhere in the code: dd-trace-rb/lib/datadog/core/environment/execution.rb Lines 9 to 12 in 65c019d
This just wasn't propagated to the EnvironmentLogger yet, given it was undergoing a major refactoring when the above changes were introduced. |
Oh, neat! I don't think the code you've linked would catch my particular case — a rails console in production. But I could make the change to that core class, if you prefer, and maybe point this environment logger at that core class? |
Hm, looking more closely I don't think Which makes me think a more reliable test for what this is trying to do might be "does this process have a tty on stdin", i.e. |
i.e. I wonder if this would be good: |
@sj26, your proposed changes are very clean :) master...sj26:dd-trace-rb:interactive-environment
We wan the environment logger to output information when: It won't bother developers. So it applies to local REPLs, as well as local test runs or rake tests. In Rails console in a production environment is probably a place where we don't want it because it's verbose. But it could be helpful if you are having issues with Datadog and is trying to debug something related to it in a Rails console in production. That being said, Rails production consoles are used much more frequently to do things other than debugging Datadog observability, so I disabling seems reasonable. Do you agree with my description above, @sj26? I want to make sure this would make sense for your use case. |
Yes, that sounds right to me 👍 The Feel free to use that branch if you like? Or I can pull that in here? Not sure how to do the testing piece though. |
Currently I get a huge DATADOG CONFIGURATION payload output when starting a rails console.
The
Rails::Console
constant is only loaded when therails console
command is run:https://github.com/rails/rails/blob/main/railties/lib/rails/commands/console/console_command.rb
It's a semi-conventional way to detect if we're running in a rails console. This PR uses its presence as a signal that we're in a repl, and so avoiding printing the diagnostic information by default.