add Exception Filter trace #482

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Owner

suwatch commented Mar 22, 2013

There are two service implementation in Kudu.

  1. IHttpHandler
  2. APIController

For HttpHandler, the runnaway exception is handled by TraceModule (see onError). For APIController (this PR), it is handled by TraceExceptionFilter.

@davidebbo davidebbo commented on the diff Mar 22, 2013

...Services.Web/Tracing/TraceExceptionFilterAttribute.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Diagnostics;
+using System.Web.Http.Filters;
+using Kudu.Contracts.Tracing;
+
+namespace Kudu.Services.Web.Tracing
+{
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
+ public sealed class TraceExceptionFilterAttribute : ExceptionFilterAttribute
+ {
+ public override void OnException(HttpActionExecutedContext context)
+ {
+ ITracer tracer = TraceServices.CurrentRequestTracer;
@davidebbo

davidebbo Mar 22, 2013

Owner

That's the magic line I was missing when I tried to do it. Getting injection to work is pretty tricky.

Owner

davidebbo commented Mar 22, 2013

:shipit:

suwatch closed this Mar 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment