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

AplicationInsightsLoggerProvider does not catch exceptions. #1969

Closed
cijothomas opened this issue Jul 17, 2020 · 1 comment
Closed

AplicationInsightsLoggerProvider does not catch exceptions. #1969

cijothomas opened this issue Jul 17, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@cijothomas
Copy link
Contributor

Describe the bug

AplicationInsightsLoggerProvider is not catching exceptions and letting them propagate to caller. This can cause applications to crash if an exception occurs inside ApplicationInsightsProvider. This is against the overall SDK principles of never throwing.
https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/LOGGING/src/ILogger/ApplicationInsightsLogger.cs#L79

Proposal : catch and log exception to EventSource.

@cijothomas cijothomas added this to the 2.15 milestone Jul 17, 2020
@cijothomas
Copy link
Contributor Author

This was found another part of AI SDK did not handle exception:
https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/BASE/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs#L208

Its also important to fix the underlying ExceptionTelemetry class to never throw.

Example exception trace:

2020-07-15T11:33:59.315067545Z System.AggregateException: An error occurred while writing to logger(s). (Invalid assembly public key. (0x8013141E))
2020-07-15T11:33:59.321326827Z  ---> System.Security.SecurityException: Invalid assembly public key. (0x8013141E)
2020-07-15T11:33:59.321343928Z    at System.Reflection.RuntimeAssembly.GetFullName(QCallAssembly assembly, StringHandleOnStack retString)
2020-07-15T11:33:59.321350228Z    at System.Reflection.RuntimeAssembly.get_FullName()
2020-07-15T11:33:59.321684343Z    at Microsoft.ApplicationInsights.Extensibility.Implementation.ExceptionConverter.GetStackFrame(StackFrame stackFrame, Int32 frameId)
2020-07-15T11:33:59.321697944Z    at Microsoft.ApplicationInsights.Extensibility.Implementation.ExceptionConverter.SanitizeStackFrame[TInput,TOutput](IList`1 inputList, Func`3 converter, Func`2 lengthGetter)
2020-07-15T11:33:59.321704144Z    at Microsoft.ApplicationInsights.Extensibility.Implementation.ExceptionConverter.ConvertToExceptionDetails(Exception exception, ExceptionDetails parentExceptionDetails)
2020-07-15T11:33:59.321717044Z    at Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ConvertExceptionTree(Exception exception, ExceptionDetails parentExceptionDetails, List`1 exceptions)
2020-07-15T11:33:59.321721845Z    at Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.UpdateData(Exception exception)
2020-07-15T11:33:59.321726545Z    at Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.set_Exception(Exception value)
2020-07-15T11:33:59.321731245Z    at Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry..ctor(Exception exception)
2020-07-15T11:33:59.322066560Z    at Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants