Skip to content

Commit

Permalink
NLogTarget - Use FlushAsync instead of synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot committed Aug 13, 2024
1 parent e623c1b commit b81d8ed
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,8 @@ protected override void FlushAsync(AsyncContinuation asyncContinuation)

try
{
this.TelemetryClient.Flush();
if (DateTime.UtcNow.AddSeconds(-30) > this.lastLogEventTime)
{
// Nothing has been written, so nothing to wait for
asyncContinuation(null);
}
else
{
// Documentation says it is important to wait after flush, else nothing will happen
// https://docs.microsoft.com/azure/application-insights/app-insights-api-custom-events-metrics#flushing-data
System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(500)).ContinueWith((task) => asyncContinuation(null));
}
}
this.TelemetryClient.FlushAsync(System.Threading.CancellationToken.None).ContinueWith(t => asyncContinuation(t.Exception));

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./ProjectsForSigning.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./ProjectsForSigning.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./ProjectsForSigning.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./ProjectsForSigning.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./examples/Examples.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./examples/Examples.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./examples/Examples.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./examples/Examples.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, netcoreapp3.1)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, netcoreapp3.1)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, netcoreapp3.1)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, netcoreapp3.1)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./LOGGING/Logging.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./LOGGING/Logging.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./LOGGING/Logging.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./LOGGING/Logging.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net452)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net452)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net452)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net452)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net6.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net6.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net6.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net6.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net472)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net472)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net472)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net472)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net480)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net480)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net480)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net480)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net462)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net7.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net462)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net7.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net462)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net7.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net462)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net7.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net8.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net8.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net8.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net8.0)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net481)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net481)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net481)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / build-test-LOGGING (windows-latest, net481)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./Everything.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./Everything.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./Everything.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / sanity-build (./Everything.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./ProjectsForSigning.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./ProjectsForSigning.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./ProjectsForSigning.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./ProjectsForSigning.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./examples/Examples.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./examples/Examples.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./examples/Examples.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./examples/Examples.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./LOGGING/Logging.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./LOGGING/Logging.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./LOGGING/Logging.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./LOGGING/Logging.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./Everything.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./Everything.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./Everything.sln)

} expected

Check failure on line 190 in LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp) (./Everything.sln)

} expected

catch (Exception ex)
{
asyncContinuation(ex);
Expand Down

0 comments on commit b81d8ed

Please sign in to comment.