Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing System.AggregateException with custom aggregate exception #120

Merged
merged 5 commits into from
Jul 9, 2021
Merged
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
23 changes: 22 additions & 1 deletion src/lib/Microsoft.Health.Logger/Telemetry/IomtTelemetryLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ public virtual void LogMetric(Common.Telemetry.Metric metric, double metricValue

public virtual void LogError(Exception ex)
{
_telemetryClient.TrackException(ex);
if (ex is AggregateException e)
{
// Address bug https://github.com/microsoft/iomt-fhir/pull/120
LogAggregateException(e);
}
else
{
_telemetryClient.TrackException(ex);
}
}

public virtual void LogTrace(string message)
Expand All @@ -41,5 +49,18 @@ public void LogMetricWithDimensions(Common.Telemetry.Metric metric, double metri
EnsureArg.IsNotNull(metric);
metric.LogMetric(_telemetryClient, metricValue);
}

private void LogAggregateException(AggregateException e)
{
if (e.InnerException != null)
{
_telemetryClient.TrackException(e.InnerException);
}

foreach (var exception in e.InnerExceptions)
{
_telemetryClient.TrackException(exception);
}
}
}
}