You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class LoggerService : ILoggerService where T : class
{
private readonly TelemetryClient _telemetryClient;
private readonly ILogger _logger;
public LoggerService(
TelemetryClient telemetryClient,
ILogger<T> logger
)
{
_telemetryClient = telemetryClient;
_logger = logger;
}
public void Flush()
{
_telemetryClient.Flush();
}
public void Dispose()
{
Flush();
}
}
And BlockingDetector log this Warning:
2019-10-01 21:02:39.607 +00:00 [Warning] Ben.Diagnostics.BlockingMonitor: Blocking method has been invoked and blocked, this can lead to threadpool starvation.
at System.Threading.Tasks.TplEtwProvider.TaskWaitBegin(Int32 OriginatingTaskSchedulerID, Int32 OriginatingTaskID, Int32 TaskID, TaskWaitBehavior Behavior, Int32 ContinueWithTaskID)at System.Threading.Tasks.Task.InternalWaitCore(Int32 millisecondsTimeout, CancellationToken cancellationToken)at Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel.Flush()at Microsoft.ApplicationInsights.TelemetryClient.Flush()at SK.Common.Logging.LoggerService`1.Dispose()
I understand, Flush should be FlushAsync(microsoft/ApplicationInsights-dotnet#482), many asked for this, but anyway, as Dispose is Synchrone, I have no other way to do it.
So maybe some people already notice it and find a correct way to flush the telemetry client?
But if not, how can I filter this issue in BlockingDetector?
The text was updated successfully, but these errors were encountered:
ServerTelemetryChannel.Flush does block as it calls TelemetryBuffer.FlushAsync().GetAwaiter().GetResult() which is an issue with ApplicationInsights as it requires 2 threads to complete as highlighted in @davidfowl's AsyncGuidance which is being moved the official docs dotnet/AspNetCore.Docs#14734. So yes it should offer a FlushAsync method.
but anyway, as Dispose is Synchrone, I have no other way to do it.
Not sure what the interface ILoggerService is, however if you are using .NET Core 3.0 you can implement IAsyncDisposable and also use it with C#8 in an async using statement; however the docs haven't been reflected to update that either yet dotnet/docs#11984
Hi,
I created a LoggerService :
public class LoggerService : ILoggerService where T : class
{
private readonly TelemetryClient _telemetryClient;
private readonly ILogger _logger;
And BlockingDetector log this Warning:
I understand, Flush should be FlushAsync(microsoft/ApplicationInsights-dotnet#482), many asked for this, but anyway, as Dispose is Synchrone, I have no other way to do it.
So maybe some people already notice it and find a correct way to flush the telemetry client?
But if not, how can I filter this issue in BlockingDetector?
The text was updated successfully, but these errors were encountered: