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

Improve console behavior in Rails applications #622

Closed
roelbondoc opened this issue Oct 25, 2024 · 6 comments · Fixed by #623
Closed

Improve console behavior in Rails applications #622

roelbondoc opened this issue Oct 25, 2024 · 6 comments · Fixed by #623
Assignees

Comments

@roelbondoc
Copy link
Member

roelbondoc commented Oct 25, 2024

Currently, the gem's behavior in rails console could use improvement, particularly around logging and automatic instrumentation. This affects both development and production environments.

Current Behavior

  • Insights is disabled by default in the console via this code
  • This default can be overridden by setting the HONEYBADGER_INSIGHTS_ENABLED environment variable
  • When Insights is enabled (e.g., in 12-factor apps that set env vars in production), console users see potentially unwanted logging output
  • Rate limit (429) responses and other Insights-related messages appear in the console output

Problems

  1. 12-factor applications typically set environment variables at the application level, making it difficult to have different behavior for console sessions
  2. Console logging can be noisy, potentially leading users to disable the gem entirely in development
  3. No clear way to explicitly enable/disable features in console sessions

Current Workaround

Set HONEYBADGER_LOGGING_TTY_LEVEL=ERROR

Potential Solutions

  1. New Console-Specific Configuration:

  2. Disable All Features in Console:

    • Treat console sessions like development mode
    • Add a way to explicitly enable features when needed
    • Similar to the current Insights-only approach but more comprehensive
  3. Improve Logging Control:

    • Allow routing different types of logs to separate files
    • Don't emit logs at all when attached to the console (this is the opposite of what Rails does by default, however — we should follow Rails conventions as closely as possible)

Questions to Consider

  • Should we maintain different defaults for development vs production consoles?
  • What features (if any) should be enabled by default in a console session?
  • How can we make the behavior more intuitive for both standard and 12-factor deployments?

Related

@joshuap joshuap changed the title [Rails Console] Improve the developer experience Improve console behavior in Rails applications Oct 25, 2024
@joshuap
Copy link
Member

joshuap commented Oct 25, 2024

@stympy @rabidpraxis @subzero10 thoughts on this?

@stympy
Copy link
Member

stympy commented Oct 25, 2024

Don't emit logs at all when attached to the console (this is the opposite of what Rails does by default, however — we should follow Rails conventions as closely as possible)

But the production Rails console doesn't log SQL queries, whereas the development console does, so if we want to follow Rails conventions, we could match that behavior for logging.

As for automatic instrumentation, I think we should disable that for all console sessions.

@joshuap
Copy link
Member

joshuap commented Oct 25, 2024

Don't emit logs at all when attached to the console (this is the opposite of what Rails does by default, however — we should follow Rails conventions as closely as possible)

But the production Rails console doesn't log SQL queries, whereas the development console does, so if we want to follow Rails conventions, we could match that behavior for logging.

As for automatic instrumentation, I think we should disable that for all console sessions.

So if we just want to keep the current behavior (but fix the 12-factor issue), we could add the explicit insights.console_enabled option, default false (see Roel's branch).

That way, Honeybadger.notify and Honeybadger.event will still report in production, and you'll see those logs in the console if that's where you're sending logs, but the automatic instrumentation will be turned off in the console.

It sounds like that's what we're leaning towards?

@stympy
Copy link
Member

stympy commented Oct 25, 2024

So if we just want to keep the current behavior (but fix the 12-factor issue), we could add the explicit insights.console_enabled option, default false (see Roel's branch).

That way, Honeybadger.notify and Honeybadger.event will still report in production, and you'll see those logs in the console if that's where you're sending logs, but the automatic instrumentation will be turned off in the console.

It sounds like that's what we're leaning towards?

Sounds good to me!

@rabidpraxis
Copy link
Contributor

👍🏻

@joshuap
Copy link
Member

joshuap commented Oct 25, 2024

@roelbondoc go ahead and submit a PR for your branch when you get the chance!

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

Successfully merging a pull request may close this issue.

4 participants