https://github.com/nikoo-asadnejad/observability
A lightweight and extensible C# class library that enables health checks, metrics, tracing, and logging to be added to any .NET application with minimal setup.
https://github.com/nikoo-asadnejad/observability
Last synced: about 1 month ago
JSON representation
A lightweight and extensible C# class library that enables health checks, metrics, tracing, and logging to be added to any .NET application with minimal setup.
- Host: GitHub
- URL: https://github.com/nikoo-asadnejad/observability
- Owner: Nikoo-Asadnejad
- Created: 2025-05-21T18:09:45.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-05-21T18:30:13.000Z (5 months ago)
- Last Synced: 2025-05-21T19:27:44.843Z (5 months ago)
- Language: C#
- Size: 280 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
# Observability Library for .NET
A lightweight and extensible C# class library that enables **health checks**, **metrics**, **tracing**, and **logging** to be added to any .NET application with minimal setup.
With a single method call during `Startup`, this library integrates observability best practices into your app, providing real-time monitoring and diagnostics for databases, caches, message brokers, APIs, and more.
---
## 🚀 Features
- ✅ Health Checks for:
- SQL Server
- Redis
- MongoDB
- RabbitMQ
- Hangfire
- External APIs
- S3 Storage
- Elasticsearch
- Network (Ping)
- SignalR hubs
- Grpc Services
- SSL Connection
- 📊 Metrics (Pluggable)
- 🔍 Tracing (Pluggable)
- 📝 Logging (Built-in)---
## 📦 Installation
1. Clone or reference the **Observability** library in your .NET project.
---## 🔧 Configuration
Add an `observability.json` file in your application root with the following structure:
```json
{
"HealthCheck": {
"ApplicationName": "YourAppName",
"Items": [
{
"Type": "Sql",
"Name": "SQL Database",
"Endpoint": "your-sql-connection-string"
},
{
"Type": "Redis",
"Name": "Redis Cache",
"Endpoint": "your-redis-endpoint"
},
{
"Type": "MongoDb",
"Name": "MongoDB",
"Endpoint": "your-mongodb-connection-string"
},
{
"Type": "RabbitMq",
"Name": "RabbitMQ",
"Endpoint": "your-rabbitmq-url"
},
{
"Type": "Hangfire",
"Name": "Hangfire",
"Endpoint": "redis-endpoint",
"AllowedFailureThreshold": 50
},
{
"Type": "ExternalApi",
"Name": "Your API",
"Endpoint": "https://your-api.com/"
},
{
"Type": "S3",
"Name": "CDN Storage",
"Endpoint": "your-s3-url",
"CdnBucketName": "your-bucket",
"CdnAccessKey": "your-access-key",
"CdnSecretKey": "your-secret-key"
},
{
"Type": "ElasticSearch",
"Name": "ELK",
"UserName": "your-username",
"Password": "your-password",
"Endpoint": "http://your-elastic-url"
},
{
"Type": "Network",
"Name": "Internal Network",
"Endpoint": "your-ip",
"PingTimeoutSecond": 5000
},
{
"Type": "SignalR",
"Name": "SignalR Hub",
"Endpoint": "https://your-hub-url"
},
{
"Type": "Grpc",
"Name": "Book-Grpc",
"Endpoint": "https://your-grpc"
},
{
"Type": "SSL",
"Name": "SSL Connection",
"Endpoint": "https://your-endpoint"
}
]
},
"AllowedIPs": [
"127.0.0.1",
"::1"
]
}
```## 🛠️ Usage
### Step 1:
Fill the `observability.json` file with the details of the components you want to monitor. Specify the health check items (e.g., databases, APIs, caches) and their respective endpoints. Additionally, define the allowed IPs that can access the /healthz endpoint. To allow unrestricted access, you can use "*" as a wildcard.### Step 2: Register Observability Services
In your `Program.cs` or `Startup.cs` (inside `ConfigureServices`):```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddObservability();
}
```## Step 3: Enable Observability Middleware and add `/healthz` endpoint.
In your `Program.cs` or `Startup.cs` (inside `Configure`):
```csharp
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.AddObservability();
}
```