Logging Exception details / properties using SharpRaven

Maybe this is more a topic on the SharpRaven GitHub page, but let’s give it a try here first:

I’m used to when an exception is logged, it’s custom public properties are also serialized and passed along.

Let’s say for example there is a custom TimeoutException, which has a ‘duration’ property. The duration property indicates what the time to timeout was, which is useful information.

This information should be available for every exception in the inner exception chain of course.

I would expect this to work out-of-the box. Is this something that if I want is, I would have to obtain myself using reflection and pass it along as extra parameters in the Raven client?

Is I didn’t see where to officially do this, I hacked something myself, by passing in missing data as ‘Extra’ information while logging an exception.
I serialized public exception properties that were not implemented by the base System.Exception.
This information, which is a Dictionary of property-value is then passed as extra information.

I know not all languages go into much detail for custom exceptions, or not all developers do this, but sometimes these custom properties contain very relevant information, as explained in the original question.
I also think these traits are applicable to multiple languages and frameworks and it would be nice if the would be taken into the Sentry model. For instance this would allow search filters for exception property values (let’s say all WebExceptions with status code 403)

A few real-life examples:

System.Net.Mail.SmtpFailedRecipientsException      : {
  "InnerExceptions": [],
  "FailedRecipient": "null",
  "StatusCode": "GeneralFailure"
System.Net.WebException                            : {
  "Status": "UnknownError",
  "Response": "null"
System.Xml.XmlException                            : {
  "LineNumber": "0",
  "LinePosition": "0",
  "SourceUri": "null"
Newtonsoft.Json.JsonReaderException                : {
  "LineNumber": "0",
  "LinePosition": "0",
  "Path": "null"

In general for any type of (web.based, server-side) exception logger one would expect this kind of information to be available: (yellow for information that I had expected expect out-of-thebox)

Now I am resorting to serializing all this information as ‘Extra’ (or ‘Additional’) data, which ís displayed somewhat userfriendly. The first section, ‘ExceptionProperties’ contains the custom exceptions’ properties. The other sections display a part of what ‘web-context’ like parameters. (the ‘instance id’ can be ignored, it’s our internal reference to the exception)

If this information an already be processed in better supported way, then I may have to review the SharpRaven code and propose a pull-request there.