Skip to content

Code quality: puts used for error logging in health check—log output lost in production #47

@tkadauke

Description

@tkadauke

Description

app/models/health_check.rb line 163 uses puts to output error backtraces:

rescue Exception => e
  # ...
  puts e.backtrace
end

Impact

  • puts writes to $stdout. In production (Heroku, systemd, containers), $stdout may be redirected, buffered, or discarded depending on the process manager.
  • The backtrace never appears in Rails logs (log/production.log), so errors are invisible to anyone watching the log file.
  • Log aggregation tools (Papertrail, Datadog) typically capture Rails.logger output, not raw $stdout.
  • The backtrace is printed without context (which check, which check_run ID).

Suggested approach

Rails.logger.error "[HealthCheck ##{id}] #{e.class}: #{e.message}"
Rails.logger.error e.backtrace.join("\n")

Or use an exception tracking service (Sentry, Honeybadger): Sentry.capture_exception(e).

Effort: trivial

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions