diff --git a/MP.IOC/Services/MetricsDbFlushService.cs b/MP.IOC/Services/MetricsDbFlushService.cs index 66e05e77..bb5e5b4f 100644 --- a/MP.IOC/Services/MetricsDbFlushService.cs +++ b/MP.IOC/Services/MetricsDbFlushService.cs @@ -61,13 +61,13 @@ namespace MP.IOC.Services { try { - var deleteConfirmed = _config.GetValue("RouteMan:RecoverHistoricalMetrics", false); + //var deleteConfirmed = _config.GetValue("RouteMan:RecoverHistoricalMetrics", false); - if (!deleteConfirmed) - { - Log.Debug("Historical metrics recovery disabled, skipping"); - return; - } + //if (!deleteConfirmed) + //{ + // Log.Debug("Historical metrics recovery disabled, skipping"); + // return; + //} Log.Info("Starting historical metrics recovery from Redis..."); @@ -133,6 +133,8 @@ namespace MP.IOC.Services if (recordsToInsert.Count > 0) { + await using var scope = _scopeFactory.CreateAsyncScope(); + var _aggrService = scope.ServiceProvider.GetRequiredService(); await _aggrService.UpsertManyAsync(recordsToInsert, false); Log.Info("[HISTORICAL] Recovered {count} hourly records for method {method}", recordsToInsert.Count, method); @@ -189,6 +191,8 @@ namespace MP.IOC.Services if (recordsToInsert.Count > 0) { + await using var scope = _scopeFactory.CreateAsyncScope(); + var _detailService = scope.ServiceProvider.GetRequiredService(); await _detailService.UpsertManyAsync(recordsToInsert, false); Log.Info("[HISTORICAL] Recovered {count} daily records for method {method}", recordsToInsert.Count, method);