public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall instrumentedMethodCall, IAgent agent, ITransaction transaction) { transaction.AttachToAsync(); var controllerContext = instrumentedMethodCall.MethodCall.MethodArguments.ExtractNotNullAs <dynamic>(0); if (controllerContext != null) { var controllerName = MvcRouteNamingHelper.TryGetControllerNameFromObject(controllerContext); var actionName = MvcRouteNamingHelper.TryGetActionNameFromRouteParameters(instrumentedMethodCall.MethodCall, controllerContext.RouteData); var httpContext = controllerContext.HttpContext; if (httpContext == null) { throw new NullReferenceException("httpContext"); } var transactionName = string.Format("{0}/{1}", controllerName, actionName); transaction.SetWebTransactionName(WebTransactionType.MVC, transactionName, TransactionNamePriority.FrameworkHigh); var segment = transaction.StartMethodSegment(instrumentedMethodCall.MethodCall, controllerName, actionName); httpContext.Items[HttpContextSegmentKey] = segment; } return(Delegates.NoOp); }
public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall instrumentedMethodCall, IAgent agent, ITransaction transaction) { transaction.AttachToAsync(); var controllerContext = instrumentedMethodCall.MethodCall.MethodArguments.ExtractNotNullAs <ControllerContext>(0); var controllerName = MvcRouteNamingHelper.TryGetControllerNameFromObject(controllerContext); var actionName = MvcRouteNamingHelper.TryGetActionNameFromRouteParameters(instrumentedMethodCall.MethodCall, controllerContext.RouteData); var transactionName = string.Format("{0}/{1}", controllerName, actionName); transaction.SetWebTransactionName(WebTransactionType.MVC, transactionName, TransactionNamePriority.FrameworkHigh); var segment = transaction.StartMethodSegment(instrumentedMethodCall.MethodCall, controllerName, actionName); if (segment == null) { return(Delegates.NoOp); } return(Delegates.GetDelegateFor(segment)); }