Getting more insight about environment on Azure


Posted on
Jul 16 2016

I'm looking at a stack trace for an error which I believe originates from one of my web apps on Azure. I have 6 or 8 different web apps which each do different things. Yet I can't tell which app the error comes from. What is the best practice for capturing the environment (perhaps) that the app is running in and having it be available in the message I see? I suppose normally at the top of the stack I would see some trace of my own code. But in this case I do not.

I have both node and c# katana web apps.

The stack trace shows that it is happening in c# from the namespaces. And I can see that there are classes in the Raygun API that appear to provide ways to add additional information to Raygun messages but I'm not sure how to use them. A code sample would help.

Let me know if you need any additional information.

Jason Fauchelle


Posted on
Jul 18 2016

Hi Stevil,

Your best option here for using Raygun4Net in a web application would be to listen to when Raygun4Net is about to send a message, and then add any additional information you want to the message object before it gets serialized and sent.

Here is the documentation with a code example of how to do something like this:

The code example includes how to provide your own RaygunClient instance to the http module if that's how you've set up Raygun4Net. (Let me know if you're not using the http module, or if you're working with WebAPI instead). This is done by changing your http application to implement the IRaygunApplication interface and return a RaygunClient instance from the GenerateRaygunClient method. When your app starts up, create the RaygunClient instance, and attach an event handler to the SendingMessage event.

Your event handler will be called any time an error report is going to be sent to Raygun, be it manually or automatically. In this event handler, you could either append to the e.Message.Details.Error.Message value, or you could set a list of tags to e.Message.Details.Tags, or even set a Dictionary of custom data to e.Message.Details.UserCustomData. (Ideally with null checks on each bit of those property chains). Just choose whichever works best for you, depending on where you want to see which app it was from.

Please let me know if you have further questions about any of this and I'll help you out.

Regards -Jason Fauchelle