Add health checks for sustainability monitoring#80
Open
rickbutterfield wants to merge 4 commits intov5/devfrom
Open
Add health checks for sustainability monitoring#80rickbutterfield wants to merge 4 commits intov5/devfrom
rickbutterfield wants to merge 4 commits intov5/devfrom
Conversation
This commit introduces three health checks to monitor website sustainability: - Page Coverage Health Check: Reports the percentage of published pages that have been tested for sustainability, with warnings for stale metrics - Carbon Rating Health Check: Evaluates the site's overall carbon footprint based on average page metrics - Green Hosting Health Check: Verifies if the website is hosted on green infrastructure using The Green Web Foundation API Also includes: - PageCoverageData model for tracking tested pages and stale metrics - SustainabilityHealthCheckSettings for configurable thresholds - CarbonRatingHelper for consistent rating calculations - Migration to change PageData column to NVARCHAR(MAX) for better compatibility - Service method to retrieve page coverage statistics Health checks can be configured via appsettings.json under Sustainability:HealthChecks section. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds Umbraco backoffice health checks to surface sustainability monitoring signals (coverage, carbon rating, and green hosting), plus supporting settings and data access/migrations.
Changes:
- Adds three new Umbraco health checks: Page Coverage, Site Carbon Rating, and Green Hosting.
- Introduces shared carbon-rating calculation helper and models for health check settings / page coverage data.
- Extends
PageMetricServicewith coverage aggregation and adds a migration to alterPageDatastorage type.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Umbraco.Community.Sustainability/SustainabilityComposer.cs | Wires up health check settings and registers a named HTTP client for Green Web Foundation calls. |
| src/Umbraco.Community.Sustainability/Services/PageMetricService.cs | Adds GetPageCoverageData for coverage/staleness aggregation. |
| src/Umbraco.Community.Sustainability/Notifications/PageMetricsNotificationHandler.cs | Adds migration step 04 and switches upgrader execution to async. |
| src/Umbraco.Community.Sustainability/Models/SustainabilityHealthCheckSettings.cs | Introduces config model for health checks (currently only stale-days). |
| src/Umbraco.Community.Sustainability/Models/PageCoverageData.cs | Adds model to return tested/stale page counts. |
| src/Umbraco.Community.Sustainability/Migrations/04_ChangePageDataToNVarcharMax.cs | Adds migration to alter PageData column type (non-SQLite). |
| src/Umbraco.Community.Sustainability/Helpers/CarbonRatingHelper.cs | Centralizes carbon grade thresholds used by the carbon rating health check. |
| src/Umbraco.Community.Sustainability/HealthChecks/PageCoverageHealthCheck.cs | New health check for sustainability coverage and stale-metric warnings. |
| src/Umbraco.Community.Sustainability/HealthChecks/CarbonRatingHealthCheck.cs | New health check to rate site carbon footprint from average metrics. |
| src/Umbraco.Community.Sustainability/HealthChecks/GreenHostingHealthCheck.cs | New health check that queries The Green Web Foundation API for hosting greenness. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Umbraco.Community.Sustainability/Services/PageMetricService.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/HealthChecks/GreenHostingHealthCheck.cs
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/HealthChecks/CarbonRatingHealthCheck.cs
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/HealthChecks/PageCoverageHealthCheck.cs
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/Migrations/04_ChangePageDataToNVarcharMax.cs
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/Models/SustainabilityHealthCheckSettings.cs
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/HealthChecks/GreenHostingHealthCheck.cs
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/HealthChecks/GreenHostingHealthCheck.cs
Outdated
Show resolved
Hide resolved
- Fix SQL queries to filter NULL NodeKey values in page coverage statistics - Improve security by logging errors and returning generic messages in GreenHostingHealthCheck - Add ILogger<GreenHostingHealthCheck> dependency for error logging - Remove unused ILocalizedTextService dependency from all three health checks - Use dynamic assembly version for User-Agent instead of hard-coded "5.0" - Update PR description to match actual implementation (remove mention of custom domains) Fixes: GitHub Copilot review issues on PR #80 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Umbraco.Community.Sustainability/HealthChecks/GreenHostingHealthCheck.cs
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/HealthChecks/GreenHostingHealthCheck.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/HealthChecks/PageCoverageHealthCheck.cs
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/Services/PageMetricService.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/HealthChecks/CarbonRatingHealthCheck.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Community.Sustainability/Notifications/PageMetricsNotificationHandler.cs
Outdated
Show resolved
Hide resolved
- Remove unused using statements from health check classes - Add proper null handling for JSON response in GreenHostingHealthCheck - Add JsonException handler to gracefully handle malformed API responses - Make Green property nullable to handle missing/null values - Fix coverage percentage calculation to cap at 100% - Ensure stale count never exceeds tested count - Update message clarity: "Tested published pages" instead of "Tested pages" - Convert PageMetricsNotificationHandler to async pattern (INotificationAsyncHandler) - Improve SQL queries to filter by published content only - Add LatestMetricByNode helper class for cleaner query logic These changes improve robustness and prevent data inconsistencies in health check reporting. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces three Umbraco health checks to monitor website sustainability metrics:
Page Coverage Health Check: Reports the percentage of published pages that have been tested for sustainability. Displays warnings when metrics become stale (configurable threshold, default 30 days). Helps identify untested content and encourages regular monitoring.
Carbon Rating Health Check: Evaluates the site's overall carbon footprint based on average page metrics (A+ to F rating). Provides actionable feedback when ratings fall below expectations. Uses consistent rating thresholds across the package.
Green Hosting Health Check: Verifies if the website is hosted on green infrastructure using The Green Web Foundation API. Checks the current hostname from the application configuration.
Health checks can be configured via
appsettings.jsonunderSustainability:HealthCheckssection. The Page Coverage health check supports a configurableStaleDaysthreshold (default: 30 days) to determine when metrics are considered stale.Files changed
HealthChecks/CarbonRatingHealthCheck.cs,HealthChecks/GreenHostingHealthCheck.cs,HealthChecks/PageCoverageHealthCheck.csHelpers/CarbonRatingHelper.cs(shared rating calculation logic)Models/PageCoverageData.cs,Models/SustainabilityHealthCheckSettings.csMigrations/04_ChangePageDataToNVarcharMax.cs(SQLite-compatible migration)Services/PageMetricService.cs(addedGetPageCoverageDatamethod)SustainabilityComposer.cs(health check configuration and HTTP client setup)