dolittle-obsolete / DotNET.Fundamentals

Reusable, fundamental abstractions and building blocks
http://www.dolittle.io
MIT License
4 stars 8 forks source link

JsonLogMessage is missing the type of the actual exception. #246

Open smithmx opened 5 years ago

smithmx commented 5 years ago

https://github.com/dolittle-fundamentals/DotNET.Fundamentals/blob/f2f2e8fefd078ece015c468c5924f94ac72bd6de/Source/Logging/Json/JsonLogMessage.cs#L25

We aren't logging enough information to diagnose the issue when their in an exception.

For example, when we invoke the Handle method on a command handler and it throws an exception, we end up with a logged error like:

{ "logLevel":"error", "timestamp":"08/08/2019 11:55:35 +00:00", "application":"18da10e9-19ad-46ab-84e6-ce79561d4cec", "boundedContext":"f5a4fbb8-7eac-4c91-a04c-3e3e3d689166", "tenantId":"5f013ac0-0ba7-487a-9687-0091f920d2b5", "environment":"Production", "correlationId":"93d1b4d2-4ea2-471d-b8a4-a45ff5a939ac", "filePath":"/Users/einari/Projects/Dolittle/Runtime/DotNET.SDK/Source/Commands.Handling/CommandHandlerInvoker.cs", "lineNumber":114, "member":"TryHandle", "message":"Failed invoking command handler \u0027Domain.MyCommandHandler, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\u0027 for command of type \u0027{[Type: Dolittle.Artifacts.Artifact]\n{ Id : 13572fd5-08ac-4874-9d83-29a48c2aade9 }{ Generation : 1 }}\n\u0027", "stackTrace":" at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)\n at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\n at Dolittle.Commands.Handling.CommandHandlerInvoker.TryHandle(CommandRequest command)" }

We don't know what exception was actually thrown from the handler and these are very important - they should be domain specific exceptions.

┆Issue is synchronized with this Asana task