Skip to content

Commit

Permalink
Fix ServerTelemetryChannel constructor exception when network info AP…
Browse files Browse the repository at this point in the history
…I throws (#1203)
  • Loading branch information
cijothomas authored Aug 30, 2019
1 parent b56dd19 commit 3906cb2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This changelog will be used to generate documentation on [release notes page](ht
- [Metric Aggregator background thread safeguards added to never throw unhandled exception.](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1179)
- [Updated version of System.Diagnostics.DiagnosticSource to 4.6.0-preview7.19362.9. Also remove marking SDK as CLS-Compliant](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1183)
- [Enhancement: Exceptions thrown by the TelemetryConfiguration will now specify the exact name of the property that could not be parsed from a config file.](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1194)
- [Fix: ServerTelemetryChannel constructor exception when network info API throws.](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1184)
- [Make BaseSDK use W3C Trace Context based correlation by default. Set TelemetryConfiguration.EnableW3CCorrelation=false to disable this.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1193)
- [Removed TelemetryConfiguration.EnableW3CCorrelation. Users should do Activity.DefaultIdFormat = ActivityIdFormat.Hierarchical; Activity.ForceDefaultIdFormat = true; to disable W3C Format](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1198)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ public void SetsMaxSenderAndBufferCapacitiesToZeroWhenNetworkIsUnavailable()
Assert.AreEqual(0, policy.MaxBufferCapacity);
}

[TestMethod]
public void InitializeCatchAllExceptionsAndDoesNotSetCapacity()
{
var network = new StubNetwork { OnIsAvailable = () => { throw new Exception("error"); } };
var policy = new NetworkAvailabilityTransmissionPolicy(network);

try
{
policy.Initialize(new StubTransmitter());
}
catch(Exception ex)
{
Assert.Fail("No exception should have been thrown from Initialize. Exception thrown: " + ex.ToString());
}

Assert.IsNull(policy.MaxSenderCapacity);
Assert.IsNull(policy.MaxBufferCapacity);
}

[TestMethod]
public void DoesNotSetMaxSenderAndBufferCapacitiesToZeroWhenNetworkIsAvailable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ private bool IsNetworkAvailable()
{
TelemetryChannelEventSource.Log.SubscribeToNetworkFailureWarning(nie.ToString());
}
catch (Exception ex)
{
TelemetryChannelEventSource.Log.SubscribeToNetworkFailureWarning(ex.ToString());
}

return result;
}
Expand Down

0 comments on commit 3906cb2

Please sign in to comment.