diff --git a/aspnetcore/src/api/Services/CooperationChoicesService.cs b/aspnetcore/src/api/Services/CooperationChoicesService.cs index 56dda83..989a865 100644 --- a/aspnetcore/src/api/Services/CooperationChoicesService.cs +++ b/aspnetcore/src/api/Services/CooperationChoicesService.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Linq; using System.Threading.Tasks; +using api.Models.Common; using api.Models.ProfileEditor; using api.Models.Ttv; using Microsoft.EntityFrameworkCore; @@ -39,7 +40,10 @@ public async Task> GetCooperationChoices(int }).AsNoTracking().ToListAsync(); stopwatch.Stop(); - _logger.LogInformation($"GetCooperationChoices. {cooperationItems.Count} items in {stopwatch.ElapsedMilliseconds}ms."); + if (stopwatch.ElapsedMilliseconds > Constants.LoggingParameters.SLOW_OPERATION_MS_THRESHOLD) + { + _logger.LogWarning($"GetCooperationChoices is slow. userprofileId={userprofileId}, forElasticsearch={forElasticsearch} in {stopwatch.ElapsedMilliseconds}ms."); + } return cooperationItems; } diff --git a/aspnetcore/src/api/Services/Profiledata/NameService.cs b/aspnetcore/src/api/Services/Profiledata/NameService.cs index 45085bb..5250514 100644 --- a/aspnetcore/src/api/Services/Profiledata/NameService.cs +++ b/aspnetcore/src/api/Services/Profiledata/NameService.cs @@ -32,7 +32,7 @@ public NameService( */ public async Task> GetProfileEditorNames(int userprofileId, bool forElasticsearch = false) { - var stopwatch = Stopwatch.StartNew(); + var namesStopwatch = Stopwatch.StartNew(); List names = await _ttvContext.FactFieldValues.Where(ffv => ffv.DimUserProfileId == userprofileId && ffv.DimNameId > 0 && ffv.DimFieldDisplaySettings.FieldIdentifier == Constants.FieldIdentifiers.PERSON_NAME @@ -78,8 +78,11 @@ public async Task> GetProfileEditorNames(int userprofile } } - stopwatch.Stop(); - _logger.LogInformation($"GetProfileEditorNames. {names.Count} items in {stopwatch.ElapsedMilliseconds}ms."); + namesStopwatch.Stop(); + if (namesStopwatch.ElapsedMilliseconds > Constants.LoggingParameters.SLOW_OPERATION_MS_THRESHOLD) + { + _logger.LogWarning($"GetProfileEditorNames is slow. userprofileId={userprofileId}, forElasticsearch={forElasticsearch}, {names.Count} items in {namesStopwatch.ElapsedMilliseconds}ms."); + } return names; } @@ -89,7 +92,7 @@ public async Task> GetProfileEditorNames(int userprofile */ public async Task> GetProfileEditorOtherNames(int userprofileId, bool forElasticsearch = false) { - var stopwatch = Stopwatch.StartNew(); + var otherNamesStopwatch = Stopwatch.StartNew(); List otherNames = await _ttvContext.FactFieldValues.Where(ffv => ffv.DimUserProfileId == userprofileId && ffv.DimNameId > 0 && ffv.DimFieldDisplaySettings.FieldIdentifier == Constants.FieldIdentifiers.PERSON_OTHER_NAMES @@ -135,10 +138,10 @@ public async Task> GetProfileEditorOtherNames(int userpr } } - stopwatch.Stop(); - if (stopwatch.ElapsedMilliseconds > Constants.LoggingParameters.SLOW_OPERATION_MS_THRESHOLD) + otherNamesStopwatch.Stop(); + if (otherNamesStopwatch.ElapsedMilliseconds > Constants.LoggingParameters.SLOW_OPERATION_MS_THRESHOLD) { - _logger.LogWarning($"GetProfileEditorOtherNames is slow. userprofileId={userprofileId}, forElasticsearch={forElasticsearch}, {otherNames.Count} items in {stopwatch.ElapsedMilliseconds}ms."); + _logger.LogWarning($"GetProfileEditorOtherNames is slow. userprofileId={userprofileId}, forElasticsearch={forElasticsearch}, {otherNames.Count} items in {otherNamesStopwatch.ElapsedMilliseconds}ms."); } return otherNames; diff --git a/aspnetcore/src/api/Services/SettingsService.cs b/aspnetcore/src/api/Services/SettingsService.cs index a5a2e99..ac8ee99 100644 --- a/aspnetcore/src/api/Services/SettingsService.cs +++ b/aspnetcore/src/api/Services/SettingsService.cs @@ -1,6 +1,7 @@  using System.Diagnostics; using System.Threading.Tasks; +using api.Models.Common; using api.Models.ProfileEditor; using api.Models.Ttv; using Microsoft.EntityFrameworkCore; @@ -36,7 +37,10 @@ public async Task GetProfileSettings(int userprofileId, bool fo }; stopwatch.Stop(); - _logger.LogInformation($"GetProfileSettings retrieved in {stopwatch.ElapsedMilliseconds} ms"); + if (stopwatch.ElapsedMilliseconds > Constants.LoggingParameters.SLOW_OPERATION_MS_THRESHOLD) + { + _logger.LogWarning($"GetProfileSettings is slow. userprofileId={userprofileId}, forElasticsearch={forElasticsearch} in {stopwatch.ElapsedMilliseconds}ms."); + } return profileSettings; }