feature: Observability: Prometheus Metrics and Grafana
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog.Context;
|
||||
using StackExchange.Redis;
|
||||
|
||||
public class SirsDetector
|
||||
@@ -12,15 +13,18 @@ public class SirsDetector
|
||||
private readonly IConnectionMultiplexer _redis;
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly ILogger<SirsDetector> _logger;
|
||||
private readonly ClinicalMetrics _metrics;
|
||||
|
||||
public SirsDetector(
|
||||
IConnectionMultiplexer redis,
|
||||
IServiceProvider services,
|
||||
ILogger<SirsDetector> logger)
|
||||
ILogger<SirsDetector> logger,
|
||||
ClinicalMetrics metrics)
|
||||
{
|
||||
_redis = redis;
|
||||
_services = services;
|
||||
_logger = logger;
|
||||
_metrics = metrics;
|
||||
}
|
||||
|
||||
public async Task<SirsResult> ProcessObservationAsync(
|
||||
@@ -151,10 +155,18 @@ public class SirsDetector
|
||||
await db.SaveChangesAsync(ct);
|
||||
await tx.CommitAsync(ct);
|
||||
|
||||
_logger.LogWarning(
|
||||
"SEPSIS_WARNING alert {AlertId} created for encounter {EncounterId} " +
|
||||
"— {Active}/4 SIRS criteria active",
|
||||
alertId, encounterId, activeCount);
|
||||
_metrics.SirsDetectionsTotal.Inc();
|
||||
_metrics.ClinicalAlertsTotal
|
||||
.WithLabels(AlertType.SepsisWarning.ToDbString(), AlertSeverity.Critical.ToDbString())
|
||||
.Inc();
|
||||
|
||||
using (LogContext.PushProperty("EncounterId", encounterId))
|
||||
using (LogContext.PushProperty("PatientId", patientId))
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"SEPSIS_WARNING created. ActiveCriteriaCount={Count} AlertId={AlertId}",
|
||||
activeCount, alertId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user