Raygun4net override api key OnApplicationStarted()
JoseMarmolejos
Posted on
Apr 08 2014
Currently we need to define the api key in an azure role's cloud configuration file (.cscfg) but the http module for Raygun4Net expects the api key to be the defined in that section of the web.config file. So the only solution I can come up, is to somehow override RaygunSettings.Settings.ApiKey which is, sadly, readonly and prevents me from doing so.
Is there another way to achieve this or tell the http module to grab the api key from somewhere else?
Callum
Posted on
Apr 08 2014
The API key can also be set when programatically using Raygun4NET, in the RaygunClient constructor:
RaygunClient client = new RaygunClient("apikey");
protected void Application_Error()
{
var exception = Server.GetLastError();
client.Send(exception);
}
Would this work for your use case?
JoseMarmolejos
Posted on
Apr 08 2014
Hey man,
Thanks for the reply. Although I really wanted to get a free ride on the http module and not do anything manually, the approach you suggested did the job. Since it's a mvc and webapi project I had to go ahead and create a HandleError() attribute for the mvc part and an HttpFilter for the web api. Here's what I ended up doing:
https://gist.github.com/jmarmolejos/10069215
Thanks a heap!
Callum
Posted on
Apr 08 2014
Ah cheers for posting the snippet, I'm sure that will be valuable for others in the future.
And yes while writing that post above I was thinking it would indeed be nice to keep the HttpModule - the provider would need a refactor here as it just creates a new RaygunClient instance which reads the key from RaygunSettings in the config as you discovered. I'll add this to the backlog so that it can make it in to a future version.
Regards,
Callum