-
Notifications
You must be signed in to change notification settings - Fork 3
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
chore: Refactor probes and add more health checks #1159
base: main
Are you sure you want to change the base?
Conversation
Warning Rate limit exceeded@arealmaas has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 18 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughWalkthroughThe pull request introduces several enhancements to the health check capabilities of the application. It adds multiple package references related to health checks and dependency injection. A new health check class for well-known endpoints is implemented, and the infrastructure is updated to include health checks for Redis and PostgreSQL. Additionally, the application's Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (4)
- src/Digdir.Domain.Dialogporten.Infrastructure/Digdir.Domain.Dialogporten.Infrastructure.csproj (1 hunks)
- src/Digdir.Domain.Dialogporten.Infrastructure/HealthChecks/WellKnownHealthChecks.cs (1 hunks)
- src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs (2 hunks)
- src/Digdir.Domain.Dialogporten.WebApi/Program.cs (3 hunks)
Additional comments not posted (9)
src/Digdir.Domain.Dialogporten.Infrastructure/Digdir.Domain.Dialogporten.Infrastructure.csproj (4)
4-4
: LGTM!The
AspNetCore.HealthChecks.NpgSql
package reference is a good addition for implementing health checks with PostgreSQL database. The version8.0.2
is a stable release.
5-5
: LGTM!The
AspNetCore.HealthChecks.Redis
package reference is a good addition for implementing health checks with Redis cache. The version8.0.1
is a stable release.
7-7
: LGTM!The
AspNetCore.HealthChecks.UI.Client
package reference is a good addition for integrating with the health checks UI. The version8.0.1
is a stable release.
13-13
: LGTM!The
Microsoft.Extensions.DependencyInjection
package reference is a good addition for dependency injection, which is typically used for registering health checks. The version8.0.0
is a stable release.src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs (3)
187-188
: LGTM!Adding a dedicated HTTP client for health checks is a good practice to isolate health check traffic from the application's main HTTP traffic. The handler lifetime of 10 seconds is reasonable for managing resources efficiently.
190-205
: Comprehensive health checks added.The addition of health checks for Redis, PostgreSQL, and well-known endpoints enhances the monitoring capabilities of the application. The configuration of each health check with a name, failure status, and tags is well-structured and allows for granular monitoring.
Using the
Unhealthy
failure status for all health checks is appropriate to indicate a critical issue when a health check fails. The tags "dependencies" and "auth" enable filtering and categorization of health check results.
33-37
: Required using statements added.The addition of the using statements for health check-related namespaces is necessary for the implementation of health checks. They import the required types and namespaces for configuring health checks in the
InfrastructureExtensions
class.src/Digdir.Domain.Dialogporten.WebApi/Program.cs (2)
135-136
: Correctly adding health checks service and self-check.The health checks service is properly configured, and the self-check with the tag
"self"
is appropriately added.
211-215
: Appropriate configuration of liveness endpoint.The
/liveness
endpoint is correctly mapped to the"self"
health check, which is suitable for liveness probes.
src/Digdir.Domain.Dialogporten.Infrastructure/HealthChecks/WellKnownHealthChecks.cs
Show resolved
Hide resolved
src/Digdir.Domain.Dialogporten.Infrastructure/HealthChecks/WellKnownHealthChecks.cs
Show resolved
Hide resolved
src/Digdir.Domain.Dialogporten.Infrastructure/HealthChecks/WellKnownHealthChecks.cs
Outdated
Show resolved
Hide resolved
src/Digdir.Domain.Dialogporten.Infrastructure/HealthChecks/WellKnownHealthChecks.cs
Outdated
Show resolved
Hide resolved
src/Digdir.Domain.Dialogporten.Infrastructure/HealthChecks/WellKnownHealthChecks.cs
Outdated
Show resolved
Hide resolved
app.MapHealthChecks("/startup", new HealthCheckOptions | ||
{ | ||
Predicate = check => check.Tags.Contains("dependencies"), | ||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing registration of dependency health checks with 'dependencies'
tag.
The endpoints /startup
, /readiness
, and /health
are configured to report on health checks tagged with "dependencies"
, but no health checks are registered with this tag in the provided code. As a result, these endpoints may not return any checks, leading to incomplete health status reports.
Consider registering health checks for your dependencies (e.g., Redis, PostgreSQL) and tagging them with "dependencies"
. Here's how you might update your health check registration:
.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy(), tags: ["self"])
+ .AddRedis(
+ builder.Configuration.GetConnectionString("Redis"),
+ name: "Redis",
+ tags: new[] { "dependencies" })
+ .AddNpgSql(
+ builder.Configuration.GetConnectionString("PostgreSQL"),
+ name: "PostgreSQL",
+ tags: new[] { "dependencies" });
Ensure that the connection strings "Redis"
and "PostgreSQL"
are correctly configured in your appsettings.json
or environment variables.
Also applies to: 216-220, 221-225
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But these are registered in InfrastructureExtensions though right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arealmaas, you're absolutely correct. The dependency health checks are registered in InfrastructureExtensions.cs
with the 'dependencies'
tag. I apologize for the oversight in my previous comment.
🐰🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries mate! We all do mistakes 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arealmaas, thank you for your understanding! 😊
(_/)
( ^.^)
/(")(")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make me a haiku poem about the code changes in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, here's a haiku about the code changes in this file:
New health checks in place,
Startup, liveness endpoints,
Dependencies checked.
…lKnownHealthChecks.cs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…lKnownHealthChecks.cs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Quality Gate passedIssues Measures |
Related to #292
Summary by CodeRabbit
New Features
/startup
,/liveness
,/readiness
, and/health
.Enhancements
Bug Fixes