HealthChecks.Publisher.Datadog is the health check publisher for Datadog.
$ dotnet add package AspNetCore.HealthChecks.Publisher.DatadogThis health check verifies the ability to communicate with Datadog. It uses the provided DogStatsdService to record a run status for the specified named service check.
By default, the DogStatsdService instance is resolved from service provider. You need to specify the name of the custom check that will be published to Datadog.
void Configure(IHealthChecksBuilder builder)
{
builder.Services.AddSingleton(sp =>
{
StatsdConfig config = new() { StatsdServerName = "127.0.0.1" };
DogStatsdService service = new();
service.Configure(config);
return service;
});
builder.AddDatadogPublisher(serviceCheckName: "myservice.healthchecks");
}
You can use the overload that requires a StatsdConfig factory method. In such case, the health check is going to create a dedicated instance of DogStatsdService that will be used only by the health check itself.
void Customization(IHealthChecksBuilder builder)
{
builder.AddDatadogPublisher(
serviceCheckName: "myservice.healthchecks",
sp => new StatsdConfig()
{
StatsdServerName = "127.0.0.1",
StatsdPort = 123,
});
}