Sphyrnidae Common Library
2.0.1
Shared Utilities/Library
|
An alert is a piece of functionality that is built into the default ILogger: Logger. If you are not using the default logger, than it will be up to you to generate alerts in the system.
An alert will be triggered whenever:
Using the default Logger, you should be sure to properly configure how Alerts will be handled in the system (eg. Do you log them, send e-mails, etc?). This is done via the LoggerConfiguration
Interface: IAlert
Mock: AlertNone
Default Implementation: Alert
using Sphyrnidae.Common.Logging.Models; namespace MyApplication.Alerts { public class MyAlert : IAlert { public virtual long MaxMilliseconds(string name) => name switch { "API-MyApplicationName-GET-/widgets" => 100, "Database-MyApplicationName-RepoConnectionName-StoredProcedure" => 200, "WebService-MyApplicationName-POST-NameOfWebServiceEndpoint" => 300, _ => 0, }; public virtual bool HttpResponseAlert(HttpResponseInfo responseInfo) { if (!responseInfo.HttpCode.HasValue || responseInfo.HttpCode.Value >= 200 || responseInfo.HttpCode.Value < 300) return false; if (responseInfo.Type == "API" && responseInfo.Route == "/widgets" && responseInfo.HttpMethod == "GET") return true; if (responseInfo.Type == "Web Service" && responseInfo.Route == "NameOfWebServiceEndpoint" && responseInfo.HttpMethod == "POST") return true; return false; } } }