From 9401d09db724f2d9d7de802f6544dcad723a55f9 Mon Sep 17 00:00:00 2001 From: Thomas Ardal Date: Tue, 12 Mar 2024 11:24:41 +0100 Subject: [PATCH] New section in heartbeats documentation about adding checks to heartbeats --- docs/setup-heartbeats.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/setup-heartbeats.md b/docs/setup-heartbeats.md index 2c73114a55..44865b7a59 100644 --- a/docs/setup-heartbeats.md +++ b/docs/setup-heartbeats.md @@ -215,10 +215,35 @@ var stopwatch = new Stopwatch(); stopwatch.Start(); // run job stopwatch.Stop(); -heartbeats.Healthy( +api.Heartbeats.Healthy( logId, heartbeatId, took: stopwatch.ElapsedMilliseconds); ``` -The value of the `Took` property is shown in the *History* modal on the *Heartbeats* page on elmah.io. \ No newline at end of file +The value of the `Took` property is shown in the *History* modal on the *Heartbeats* page on elmah.io. + +### Checks + +> Checks require `Elmah.Io.Client` version `5.1.*` or newer. + +Some sites and services implement a range of different checks to decide if the program is healthy or not. Consider an ASP.NET Core website that verifies that both a connection to a database and a service bus can be established. In this example, a failing heartbeat to elmah.io can be decorated with one or more `Checks`: + +```csharp +api.Heartbeats.Unhealthy(logId, heartbeatId, checks: new List +{ + new Check + { + Name = "Database", + Result = "Unhealthy", + Reason = "Could not connect to database" + }, + new Check + { + Name = "Service Bus", + Result = "Healthy" + }, +}); +``` + +When logging checks in a heartbeat, the elmah.io UI will list each check on the *Root Cause* tab part of the unhealthy heartbeat error. \ No newline at end of file