exceptionless / Exceptionless.Net

Exceptionless clients for the .NET platform
https://exceptionless.com
Other
551 stars 142 forks source link

Fixed issues with async event handlers and improved trace logging #306

Closed niemyjski closed 1 year ago

niemyjski commented 1 year ago

Found a case where process exit and unhandled event handlers will return early due to being marked async causing early exit. This could potentially (unlikely) cause a dead lock on shutdown due to GetAwaiter().GetResult() but benefits greatly outweigh (I was also unable to cause this scenario with a deadlock)

Also, we may want to consider having our internal trace loggers implement disposable so flush is called (may be happing today by ioc but flush and dispose is not called by default)

I also greatly improved logging of the client to give more visibility of what is happening instead of only logging on error:

2023-05-09 08:01:44.3824 Info  ExceptionlessClient: Startup called ApiKey=MY_API_KEY ServerUrl=https://localhost:5000
2023-05-09 08:01:44.5095 Info  ExceptionlessClient: Startup finished
2023-05-09 08:01:49.7881 Info  ExceptionlessClient: ProcessExit called
2023-05-09 08:01:49.7884 Info  ExceptionlessClient: Processing event queue
2023-05-09 08:01:49.7888 Info  ExceptionlessClient: Sending Session End Heartbeat
2023-05-09 08:01:49.8143 Info  DefaultEventQueue: Sent 1 events to "https://localhost:5000".
2023-05-09 08:01:50.0305 Info  ExceptionlessClient: ProcessExit finished