From 7ea567004958a9bf77654628beed361f1e125b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Stenr=C3=B8jl?= <51327761+dstenroejl@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:09:08 +0100 Subject: [PATCH] Remove custom properties (#280) --- .../documents/release-notes/release-notes.md | 4 +++ .../Common.Abstractions.csproj | 2 +- .../Common.Security/Common.Security.csproj | 2 +- source/App/source/Common/Common.csproj | 2 +- .../App/source/FunctionApp/FunctionApp.csproj | 2 +- .../source/WebApp/Hosting/RepeatingTrigger.cs | 27 ++++++------------- source/App/source/WebApp/WebApp.csproj | 2 +- 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/source/App/documents/release-notes/release-notes.md b/source/App/documents/release-notes/release-notes.md index 24b3485f0..d45ef4b6f 100644 --- a/source/App/documents/release-notes/release-notes.md +++ b/source/App/documents/release-notes/release-notes.md @@ -1,5 +1,9 @@ # App Release notes +## Version 8.3.1 + +- Removed custom property "HostedService" and structured logging placeholder "Worker" from `RepeatingTrigger` because the same information is available in the property `CategoryName`. + ## Version 8.3.0 - Updated package version for `Energinet.DataHub.Core.JsonSerialization`. diff --git a/source/App/source/Common.Abstractions/Common.Abstractions.csproj b/source/App/source/Common.Abstractions/Common.Abstractions.csproj index 90fbd44a3..fea00ff37 100644 --- a/source/App/source/Common.Abstractions/Common.Abstractions.csproj +++ b/source/App/source/Common.Abstractions/Common.Abstractions.csproj @@ -27,7 +27,7 @@ limitations under the License. Energinet.DataHub.Core.App.Common.Abstractions - 8.3.0$(VersionSuffix) + 8.3.1$(VersionSuffix) Azure Function Common Abstractions Library Energinet-DataHub Energinet-DataHub diff --git a/source/App/source/Common.Security/Common.Security.csproj b/source/App/source/Common.Security/Common.Security.csproj index dc05e9c17..e882408fd 100644 --- a/source/App/source/Common.Security/Common.Security.csproj +++ b/source/App/source/Common.Security/Common.Security.csproj @@ -26,7 +26,7 @@ limitations under the License. Energinet.DataHub.Core.App.Common.Security - 8.3.0$(VersionSuffix) + 8.3.1$(VersionSuffix) Azure Function Common Security Library Energinet-DataHub Energinet-DataHub diff --git a/source/App/source/Common/Common.csproj b/source/App/source/Common/Common.csproj index 04fd20568..94fca0329 100644 --- a/source/App/source/Common/Common.csproj +++ b/source/App/source/Common/Common.csproj @@ -27,7 +27,7 @@ limitations under the License. Energinet.DataHub.Core.App.Common - 8.3.0$(VersionSuffix) + 8.3.1$(VersionSuffix) Azure Function Common Library Energinet-DataHub Energinet-DataHub diff --git a/source/App/source/FunctionApp/FunctionApp.csproj b/source/App/source/FunctionApp/FunctionApp.csproj index 627965a22..1084f3609 100644 --- a/source/App/source/FunctionApp/FunctionApp.csproj +++ b/source/App/source/FunctionApp/FunctionApp.csproj @@ -27,7 +27,7 @@ limitations under the License. Energinet.DataHub.Core.App.FunctionApp - 8.3.0$(VersionSuffix) + 8.3.1$(VersionSuffix) Azure Function App Library Energinet-DataHub Energinet-DataHub diff --git a/source/App/source/WebApp/Hosting/RepeatingTrigger.cs b/source/App/source/WebApp/Hosting/RepeatingTrigger.cs index 993e5d920..56444cb6a 100644 --- a/source/App/source/WebApp/Hosting/RepeatingTrigger.cs +++ b/source/App/source/WebApp/Hosting/RepeatingTrigger.cs @@ -31,8 +31,6 @@ public abstract class RepeatingTrigger : BackgroundService, IRepeating private readonly IServiceProvider _serviceProvider; private readonly ILogger _logger; private readonly TimeSpan _delayBetweenExecutions; - private readonly string _serviceName; - private readonly Dictionary _loggingScope; private DateTimeOffset _activityTimeStamp; @@ -44,9 +42,6 @@ protected RepeatingTrigger( _serviceProvider = serviceProvider; _logger = logger; _delayBetweenExecutions = delayBetweenExecutions; - - _serviceName = GetType().Name; - _loggingScope = new Dictionary { ["HostedService"] = _serviceName }; } public DateTimeOffset LastTimeActivityRegistered => _activityTimeStamp; @@ -55,26 +50,20 @@ protected RepeatingTrigger( public override async Task StopAsync(CancellationToken cancellationToken) { - using (_logger.BeginScope(_loggingScope)) - { - await base.StopAsync(cancellationToken).ConfigureAwait(false); - _logger.LogWarning("{Worker} has stopped at {Time}", _serviceName, DateTimeOffset.Now); - } + await base.StopAsync(cancellationToken).ConfigureAwait(false); + _logger.LogWarning("Worker has stopped at {Time}.", DateTimeOffset.Now); } protected override async Task ExecuteAsync(CancellationToken stoppingToken) { UpdateIsActive(); - using (_logger.BeginScope(_loggingScope)) - { - _logger.LogInformation("{Worker} started", _serviceName); + _logger.LogInformation("Worker started."); - while (!stoppingToken.IsCancellationRequested) - { - await InvokeAsync(stoppingToken).ConfigureAwait(false); - await Task.Delay(_delayBetweenExecutions, stoppingToken).ConfigureAwait(false); - } + while (!stoppingToken.IsCancellationRequested) + { + await InvokeAsync(stoppingToken).ConfigureAwait(false); + await Task.Delay(_delayBetweenExecutions, stoppingToken).ConfigureAwait(false); } } @@ -102,7 +91,7 @@ private async Task InvokeAsync(CancellationToken cancellationToken) } catch (Exception e) { - _logger.LogError(e, "Unhandled exception in {Worker}", _serviceName); + _logger.LogError(e, "Unhandled exception in worker."); } } diff --git a/source/App/source/WebApp/WebApp.csproj b/source/App/source/WebApp/WebApp.csproj index ac57cbfee..84f27dc8d 100644 --- a/source/App/source/WebApp/WebApp.csproj +++ b/source/App/source/WebApp/WebApp.csproj @@ -27,7 +27,7 @@ limitations under the License. Energinet.DataHub.Core.App.WebApp - 8.3.0$(VersionSuffix) + 8.3.1$(VersionSuffix) Azure Web App Library Energinet-DataHub Energinet-DataHub