Skip to content

Commit

Permalink
Remove custom properties (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstenroejl authored Jan 18, 2024
1 parent edd9cda commit 7ea5670
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 24 deletions.
4 changes: 4 additions & 0 deletions source/App/documents/release-notes/release-notes.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.

<PropertyGroup>
<PackageId>Energinet.DataHub.Core.App.Common.Abstractions</PackageId>
<PackageVersion>8.3.0$(VersionSuffix)</PackageVersion>
<PackageVersion>8.3.1$(VersionSuffix)</PackageVersion>
<Title>Azure Function Common Abstractions Library</Title>
<Company>Energinet-DataHub</Company>
<Authors>Energinet-DataHub</Authors>
Expand Down
2 changes: 1 addition & 1 deletion source/App/source/Common.Security/Common.Security.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ limitations under the License.

<PropertyGroup>
<PackageId>Energinet.DataHub.Core.App.Common.Security</PackageId>
<PackageVersion>8.3.0$(VersionSuffix)</PackageVersion>
<PackageVersion>8.3.1$(VersionSuffix)</PackageVersion>
<Title>Azure Function Common Security Library</Title>
<Company>Energinet-DataHub</Company>
<Authors>Energinet-DataHub</Authors>
Expand Down
2 changes: 1 addition & 1 deletion source/App/source/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.

<PropertyGroup>
<PackageId>Energinet.DataHub.Core.App.Common</PackageId>
<PackageVersion>8.3.0$(VersionSuffix)</PackageVersion>
<PackageVersion>8.3.1$(VersionSuffix)</PackageVersion>
<Title>Azure Function Common Library</Title>
<Company>Energinet-DataHub</Company>
<Authors>Energinet-DataHub</Authors>
Expand Down
2 changes: 1 addition & 1 deletion source/App/source/FunctionApp/FunctionApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.

<PropertyGroup>
<PackageId>Energinet.DataHub.Core.App.FunctionApp</PackageId>
<PackageVersion>8.3.0$(VersionSuffix)</PackageVersion>
<PackageVersion>8.3.1$(VersionSuffix)</PackageVersion>
<Title>Azure Function App Library</Title>
<Company>Energinet-DataHub</Company>
<Authors>Energinet-DataHub</Authors>
Expand Down
27 changes: 8 additions & 19 deletions source/App/source/WebApp/Hosting/RepeatingTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public abstract class RepeatingTrigger<TService> : BackgroundService, IRepeating
private readonly IServiceProvider _serviceProvider;
private readonly ILogger _logger;
private readonly TimeSpan _delayBetweenExecutions;
private readonly string _serviceName;
private readonly Dictionary<string, object> _loggingScope;

private DateTimeOffset _activityTimeStamp;

Expand All @@ -44,9 +42,6 @@ protected RepeatingTrigger(
_serviceProvider = serviceProvider;
_logger = logger;
_delayBetweenExecutions = delayBetweenExecutions;

_serviceName = GetType().Name;
_loggingScope = new Dictionary<string, object> { ["HostedService"] = _serviceName };
}

public DateTimeOffset LastTimeActivityRegistered => _activityTimeStamp;
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/App/source/WebApp/WebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.

<PropertyGroup>
<PackageId>Energinet.DataHub.Core.App.WebApp</PackageId>
<PackageVersion>8.3.0$(VersionSuffix)</PackageVersion>
<PackageVersion>8.3.1$(VersionSuffix)</PackageVersion>
<Title>Azure Web App Library</Title>
<Company>Energinet-DataHub</Company>
<Authors>Energinet-DataHub</Authors>
Expand Down

0 comments on commit 7ea5670

Please sign in to comment.