-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LNK-2883: Added Kafka health check to .NET services (#494)
Also added a missing health check endpoint to the Submission service. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Enhanced health monitoring capabilities by integrating Kafka health checks across multiple services. - Added a dedicated Kafka topic for health checks in the Docker configuration. - **Bug Fixes** - Improved logging setup to exclude specific request paths related to health checks. - **Documentation** - Updated comments throughout the code for clarity on health check configurations. These enhancements improve the application's reliability and monitoring of Kafka services, ensuring better operational oversight. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
13 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
48 changes: 48 additions & 0 deletions
48
DotNet/Shared/Application/Health/KafkaHealthConfiguration.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Confluent.Kafka; | ||
using HealthChecks.Kafka; | ||
using LantanaGroup.Link.Shared.Application.Models.Configs; | ||
|
||
namespace LantanaGroup.Link.Shared.Application.Health | ||
{ | ||
public class KafkaHealthCheckConfiguration | ||
{ | ||
private KafkaConnection _connection; | ||
private string _serviceName; | ||
|
||
public KafkaHealthCheckConfiguration(KafkaConnection connection, string serviceName) | ||
{ | ||
_connection = connection; | ||
_serviceName = serviceName; | ||
} | ||
|
||
public KafkaHealthCheckOptions GetHealthCheckOptions() | ||
{ | ||
var producerConfig = new ProducerConfig() | ||
{ | ||
BootstrapServers = string.Join(", ", _connection.BootstrapServers), | ||
MessageTimeoutMs = 3000 | ||
}; | ||
|
||
if (_connection.SaslProtocolEnabled) | ||
{ | ||
producerConfig.SaslMechanism = SaslMechanism.Plain; | ||
producerConfig.SecurityProtocol = SecurityProtocol.SaslPlaintext; | ||
producerConfig.SaslUsername = _connection.SaslUsername; | ||
producerConfig.SaslPassword = _connection.SaslPassword; | ||
} | ||
|
||
return new KafkaHealthCheckOptions() | ||
{ | ||
Configuration = producerConfig, | ||
MessageBuilder = MessageBuilder, | ||
Topic = "Service-Healthcheck" | ||
}; | ||
} | ||
|
||
private Message<string, string> MessageBuilder(KafkaHealthCheckOptions options) | ||
{ | ||
var utcDate = DateTime.UtcNow; | ||
return new Message<string, string>() { Key = _serviceName, Value = $"Service health check on {utcDate} ({utcDate.Kind})" }; | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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