Deploying an AI application without observability is like flying blind. Hazina includes built-in monitoring, health checks, and structured logging so you always know what your application is doing.
Health Checks
builder.Services.AddHazinaHealthChecks(options => {
options.AddLLMProviderCheck(); // Can we reach the AI API?
options.AddDatabaseCheck(); // Is the database responding?
options.AddDocumentStoreCheck(); // Is the vector store healthy?
options.AddPluginSystemCheck(); // Are plugins compiled and cached?
});
app.MapHealthChecks("/health");
Hit /health and get a structured status response:
{
"status": "Healthy",
"checks": {
"llm_provider": { "status": "Healthy", "latency_ms": 234 },
"database": { "status": "Healthy", "latency_ms": 3 },
"document_store": { "status": "Healthy", "documents": 1523 },
"plugin_system": { "status": "Healthy", "plugins_loaded": 7 }
}
}
Structured Logging
Hazina logs every significant operation with structured data:
// Automatic log entries:
// [INFO] AI request to openai/gpt-4o completed in 1234ms (150 tokens in, 89 tokens out)
// [INFO] RAG query "vacation policy" matched 3 documents (best score: 0.92)
// [WARN] Plugin "DataTransform" execution took 28s (limit: 30s)
// [ERROR] AI provider "anthropic" returned 429, retrying in 2s (attempt 2/3)
Metrics
Track key metrics over time:
- AI calls – Count, latency, token usage, cost estimate
- RAG queries – Query count, relevance scores, cache hit rate
- Plugin executions – Count, duration, success/failure rate
- API requests – Per-entity CRUD operation counts
Cost Tracking
var metrics = serviceProvider.GetRequiredService<IHazinaMetrics>();
var usage = await metrics.GetUsageSummaryAsync(
from: DateTime.UtcNow.AddDays(-30),
to: DateTime.UtcNow
);
Console.WriteLine($"Total AI calls: {usage.TotalCalls}");
Console.WriteLine($"Total tokens: {usage.TotalTokens:N0}");
Console.WriteLine($"Estimated cost: ");
Console.WriteLine($"Avg latency: {usage.AvgLatencyMs}ms");
In the next post, we’ll cover EF Core integration – how Hazina works with Entity Framework Core.
Terug naar overzicht