forked from NancyFx/Nancy
-
Notifications
You must be signed in to change notification settings - Fork 0
Nancy and New Relic
thefringeninja edited this page Sep 21, 2012
·
1 revision
New Relic is a nice tool used to monitor applications and collect performance metrics running on pretty much any platform, including .NET. Wiring up Nancy with New Relic is a cinch! Be sure to install the appropriate packages first. In the following example, we identify each new Relic transaction as the HTTP Method and the Route. Otherwise all transactions show up as NancyHttpHandler - not very useful! We also log all exceptions via the error pipeline.
using NewRelicAgent = NewRelic.Api.Agent.NewRelic; // protip: don't give class and namespace the same name. it's awkward.
public class NewRelicStartup : IApplicationStartup
{
private readonly IRouteResolver routeResolver;
public NewRelicStartup(IRouteResolver routeResolver)
{
this.routeResolver = routeResolver;
}
public void Initialize(IPipelines pipelines)
{
pipelines.BeforeRequest.AddItemToStartOfPipeline(
context =>
{
var route = routeResolver.Resolve(context);
if (route == null || route.Item1 == null || route.Item1.Description == null) // probably not necessary but don't want the chance of losing visibility on anything
{
NewRelicAgent.SetTransactionName(
context.Request.Method,
context.Request.Url.ToString());
}
else
{
NewRelicAgent.SetTransactionName(
route.Item1.Description.Method,
route.Item1.Description.Path);
}
return null;
});
pipelines.OnError.AddItemToEndOfPipeline(
(context, ex) =>
{
NewRelicAgent.NoticeError(
ex);
return null;
});
}
}- Taking a look at the DynamicDictionary
- The before and after module hooks
- Model binding
- Bootstrapper
- View Engines
- View location conventions
- Testing your application
- The root path
- Managing static content
- Diagnostics
- Adding a custom FavIcon
- The Application Before, After and OnError pipelines
- Generating a custom error page
- The cryptography helpers
- Content negotiation
- Authentication
- More to come
- Hosting Nancy with ASP.NET
- Hosting Nancy with WCF
- Hosting Nancy with Azure
- Hosting Nancy with OWIN
- Hosting Nancy with Umbraco
- Hosting Nancy with Nginx on Ubuntu
- Self Hosting Nancy
- Implementing a Host
- Accessing the client certificate when using SSL
- Blog Posts, Video & Audio
- Async-Beta (Async Beta)