Skip to content

SimpleObservability/SimpleObservability.Client.DotNet

Repository files navigation

Simple: Observability Client : .NET

A simple .NET client for your health endpoint

Summary

A lightweight .NET library that provides a standardized schema for exposing service health information. Use this library to make your services compatible with the Simple Observability monitoring dashboard.

Key Features:

  • 📊 Standard health metadata schema
  • 🚀 Zero-configuration setup
  • 🎯 Simple POCO classes
  • ✅ Compatible with ASP.NET Core Minimal APIs and MVC
  • 🔍 Optional additional metadata support

Installation

dotnet add package WorldDomination.SimpleObservability

Quick Start

Basic Health Endpoint

Add a /healthz endpoint to your ASP.NET Core application:

using WorldDomination.SimpleObservability;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/healthz", () =>
{
    var health = new HealthMetadata
    {
        ServiceName = "My API Service",
        Version = "1.0.0",
        Environment = "Production",
        Status = HealthStatus.Healthy
    };
    
    return Results.Json(health);
});

app.Run();

Advanced Example with Additional Metadata

app.MapGet("/healthz", () =>
{
    var health = new HealthMetadata
    {
        ServiceName = "My API Service",
        Version = "1.2.3",
        Environment = "Production",
        Status = HealthStatus.Healthy,
        Timestamp = DateTimeOffset.UtcNow,
        HostName = Environment.MachineName,
        Uptime = TimeSpan.FromHours(24),
        Description = "All systems operational",
        AdditionalMetadata = new Dictionary<string, string>
        {
            ["Database"] = "Connected",
            ["Cache"] = "Redis v7.0",
            ["Region"] = "us-west-2"
        }
    };
    
    return Results.Json(health);
});

Health Status Values

  • HealthStatus.Healthy - Service is operating normally.
  • HealthStatus.Degraded - Service is operational but experiencing issues.
  • HealthStatus.Unhealthy - Service is not operating correctly.

JSON Response Example

{
  "serviceName": "My API Service",
  "version": "1.2.3",
  "environment": "Production",
  "status": "Healthy",
  "timestamp": "2024-01-15T10:30:00Z",
  "hostName": "server-01",
  "uptime": "1.00:00:00",
  "description": "All systems operational",
  "additionalMetadata": {
    "database": "Connected",
    "cache": "Redis v7.0",
    "region": "us-west-2"
  }
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

See LICENSE for details.

About

DotNet client making it simple to return the SimpleObservability schema

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors

Languages