Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

LiveMetrics background thread safeguards added to never throw unhandled exception #1246

Merged
merged 2 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 2.11.0-beta2
- [Add NetStandard2.0 Target for WindowsServerPackage](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/1212)
- [Add NetStandard2.0 Target for DependencyCollector](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/1212)
- [QuickPulse/LiveMetrics background thread safeguards added to never throw unhandled exception.](https://github.com/microsoft/ApplicationInsights-dotnet-server/issues/1088)

## Version 2.11.0-beta1
- [Add support for Event Counter collection.](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/1222)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Threading;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing;

internal class QuickPulseThreadModuleScheduler : IQuickPulseModuleScheduler
{
Expand Down Expand Up @@ -47,7 +48,23 @@ public void Dispose()

private void Worker(object state)
{
(state as Action<CancellationToken>)?.Invoke(this.cancellationTokenSource.Token);
try
{
(state as Action<CancellationToken>)?.Invoke(this.cancellationTokenSource.Token);
}
catch (Exception ex)
{
// This is a Thread, and we don't want any exception thrown ever from this part as this would cause application crash.
try
{
QuickPulseEventSource.Log.UnknownErrorEvent(ex.ToInvariantString());
}
catch (Exception)
{
// Intentionally empty. If EventSource writing itself is failing as well, there is nothing more to be done here.
// The best that can be done is atleast prevent application crash due to unhandledexception from Thread.
}
}
}
}
}
Expand Down