QuackAlert 1.1.0
dotnet add package QuackAlert --version 1.1.0
NuGet\Install-Package QuackAlert -Version 1.1.0
<PackageReference Include="QuackAlert" Version="1.1.0" />
<PackageVersion Include="QuackAlert" Version="1.1.0" />
<PackageReference Include="QuackAlert" />
paket add QuackAlert --version 1.1.0
#r "nuget: QuackAlert, 1.1.0"
#:package QuackAlert@1.1.0
#addin nuget:?package=QuackAlert&version=1.1.0
#tool nuget:?package=QuackAlert&version=1.1.0
Quackalert
QuackAlert is a lightweight monitoring and alert library for .NET applications, designed to capture HTTP 5xx errors and send real-time email notifications.
✨ Features
- Automatic HTTP 5xx error capture
- Simple configuration via Options Pattern
- Comprehensive request tracking with duration, timestamp, and correlation IDs
- Detailed exception information
- Environment and performance metrics
- Distributed tracing support with TraceId and ParentTraceId
📦 Installation
dotnet add package QuackAlert
Or via NuGet Package Manager:
Install-Package QuackAlert
🚀 Quick Start
1. Configuration via appsettings.json (Recommended)
{
"QuackAlert": {
"Enabled": true,
"Environment": "Production",
"Email": {
"SmtpHost": "smtp.gmail.com",
"SmtpPort": 587,
"SmtpUser": "your-email@gmail.com",
"SmtpPassword": "your-app-password",
"From": "your-email@gmail.com",
"To": "recipient@email.com",
"EnableSsl": true
}
}
}
<code style="color: red">⚠️ In production environments, avoid storing sensitive email configuration values directly inappsettings.json. </code>
<code style="color: red">Prefer supplying these values through environment variables, for example <code style="color: green">QuackAlert__Email__SmtpPassword.</code></code>
<code style="color: red">Any values defined in appsettings.json will be automatically overridden when the corresponding environment variables are provided</code>
And in Program.cs:
using QuackAlert.Extensions;
using QuackAlert.Enums;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddQuackAlert(options =>
{
builder.Configuration.GetSection("QuackAlert").Bind(options);
});
var app = builder.Build();
// Add middleware
app.UseQuackAlert();
app.Run();
2. Configuration from Code
using QuackAlert.Extensions;
using QuackAlert.Enums;
var builder = WebApplication.CreateBuilder(args);
// Add QuackAlert
builder.Services.AddQuackAlert(options =>
{
options.Enabled = true;
options.Environment = EnvironmentType.Production;
options.Email.SmtpHost = "smtp.gmail.com";
options.Email.SmtpPort = 587;
options.Email.SmtpUser = "your-email@gmail.com";
options.Email.SmtpPassword = "your-app-password";
options.Email.From = "your-email@gmail.com";
options.Email.To = "recipient@email.com";
options.Email.EnableSsl = true;
});
var app = builder.Build();
// Add middleware
app.UseQuackAlert();
app.Run();
⚙️ Configuration
QuackAlertOptions
| Property | Type | Default | Description |
|---|---|---|---|
Enabled |
bool |
true |
Enables or disables QuackAlert |
Environment |
EnvironmentType |
Production |
Sets the environment (Development, Staging, Production) |
Email |
EmailOptions |
- | Email configuration settings |
EmailOptions
| Property | Type | Default | Description |
|---|---|---|---|
SmtpHost |
string |
"" |
SMTP server |
SmtpPort |
int |
587 |
SMTP port |
SmtpUser |
string |
"" |
SMTP username |
SmtpPassword |
string |
"" |
SMTP password |
From |
string |
"" |
Sender email address |
To |
string |
"" |
Recipient email address |
EnableSsl |
bool |
true |
Enables SSL/TLS |
Note: Email sending is only activated when Enabled = true AND Environment = Production.
📊 What Gets Captured
QuackAlert automatically monitors and captures comprehensive diagnostic information:
Request Information
- ✅ HTTP method (GET, POST, etc.)
- ✅ Request path and query string
- ✅ Protocol version (HTTP/1.1, HTTP/2, etc.)
- ✅ Scheme (http/https)
- ✅ Host information
- ✅ User-Agent
- ✅ Content length
Response Information
- ✅ HTTP status code
- ✅ Response content length
Tracing & Correlation
- ✅ TraceId for distributed tracing
- ✅ CorrelationId for request tracking
- ✅ ParentTraceId for nested operations
Performance Metrics
- ✅ Request duration in milliseconds
- ✅ Request timestamp
Exception Details
- ✅ Exception type
- ✅ Exception message
- ✅ Full exception stack trace
Environment Information
- ✅ Machine name
- ✅ Application version
Email Example
When a 5xx error occurs, you'll receive a formatted HTML email containing:
{
"StatusCode": 500,
"TraceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
"CorrelationId": "0HN4DKQ8F2MKL:00000001",
"ParentTraceId": null,
"Timestamp": "2024-12-20T10:30:45.123456Z",
"Request": {
"Path": {
"Value": "/api/users",
"HasValue": true
},
"Method": "POST",
"Query": "?page=1&limit=10",
"Protocol": "HTTP/2",
"Scheme": "https",
"Host": "api.example.com",
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"ContentLength": 256
},
"Response": {
"StatusCode": 500,
"ContentLength": null
},
"Performance": {
"DurationMs": 1250
},
"Environment": {
"MachineName": "web-server-01",
"Version": "1.0.0.0"
},
"Exception": {
"Type": "NullReferenceException",
"Message": "Object reference not set to an instance of an object"
}
}
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- System.Diagnostics.DiagnosticSource (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.