Skip to content

feat: add opt-in application health checks with Oh Dear integration#126

Merged
ManukMinasyan merged 9 commits intomainfrom
feat/health-checks
Feb 16, 2026
Merged

feat: add opt-in application health checks with Oh Dear integration#126
ManukMinasyan merged 9 commits intomainfrom
feat/health-checks

Conversation

@ManukMinasyan
Copy link
Copy Markdown
Contributor

@ManukMinasyan ManukMinasyan commented Feb 16, 2026

Summary

  • Install spatie/laravel-health with CPU load and security advisories checks
  • Register 15 health checks in a dedicated HealthServiceProvider gated behind HEALTH_CHECKS_ENABLED env var (default: off)
  • Configure InMemoryHealthResultStore (no migration needed)
  • Oh Dear endpoint auto-enables when OH_DEAR_HEALTH_CHECK_SECRET is set
  • Schedule health check commands only when enabled — zero overhead for users who don't opt in

Checks included

DatabaseConnection, DatabaseConnectionCount, DatabaseSize, DatabaseTableSize, Redis, RedisMemoryUsage, Horizon, Queue, UsedDiskSpace, CpuLoad, DebugMode, Environment, Schedule, SecurityAdvisories, ApplicationCache

Test plan

  • Health checks not registered when HEALTH_CHECKS_ENABLED is unset/false
  • All 15 checks registered when enabled
  • PHPStan passes with 0 errors
  • Pint formatting passes
  • Deploy to staging, set env vars, verify Oh Dear receives health check results

Copilot AI review requested due to automatic review settings February 16, 2026 03:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in application health checking system using Spatie Laravel Health, with optional Oh Dear reporting, intended to be disabled by default and enabled via environment/config.

Changes:

  • Introduces HealthServiceProvider that registers 15 Spatie health checks when HEALTH_CHECKS_ENABLED is enabled.
  • Adds Spatie Health configuration (in-memory result store) and Oh Dear endpoint configuration.
  • Adds scheduling for health check commands and a basic feature test to verify checks are gated by configuration.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/Providers/HealthServiceProvider.php Registers the suite of health checks behind an enable flag.
bootstrap/providers.php Adds the new HealthServiceProvider to the app’s provider list.
routes/console.php Schedules Spatie Health commands when health checks are enabled.
config/health.php Adds Spatie Health + Oh Dear endpoint configuration.
config/app.php Adds health_checks_enabled config flag backed by HEALTH_CHECKS_ENABLED.
tests/Feature/HealthChecks/HealthServiceProviderTest.php Verifies checks are registered only when enabled.
.env.example Documents opt-in env vars for health checks / Oh Dear secret.
composer.json Adds Spatie health packages (health, cpu-load check, security advisories check).
composer.lock Locks newly added dependencies.
Comments suppressed due to low confidence (2)

routes/console.php:14

  • This project already centralizes scheduled tasks in bootstrap/app.php via ->withSchedule(...). Adding scheduling logic in routes/console.php splits scheduling configuration across two locations, making it easier to miss tasks during future maintenance. Consider moving these Schedule::command(...) registrations into the existing withSchedule closure (still gated by config('app.health_checks_enabled')).
    config/health.php:82
  • The comment block starting here is not indented like the rest of the config file and uses a PHPDoc-style /** ... */ block inside an array, which is inconsistent with the surrounding config comment style. Align the indentation and use the same /* ... */ style used elsewhere in config/* for consistency (and ensure the commented config line would be syntactically correct if uncommented).

@ManukMinasyan ManukMinasyan merged commit 02dbedd into main Feb 16, 2026
9 checks passed
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 this pull request may close these issues.

2 participants