Ejemplo n.º 1
0
        private void AfterEvent(MethodCall methodCall, IAgent agent, string eventName, HttpApplication httpApplication)
        {
            if (httpApplication == null)
            {
                throw new ArgumentNullException("httpApplication");
            }

            var httpContext = httpApplication.Context;

            if (httpContext == null)
            {
                throw new NullReferenceException("httpApplication.Context");
            }

            var segment = agent.CastAsSegment(httpContext.Items[HttpContextActions.HttpContextSegmentKey]);

            httpContext.Items[HttpContextActions.HttpContextSegmentKey] = null;
            segment.End();

            if (eventName == "EndRequest")
            {
                HttpContextActions.TransactionShutdown(agent, httpContext);
                agent.CurrentTransaction.End();
            }
        }
Ejemplo n.º 2
0
        public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall instrumentedMethodCall, IAgent agent, ITransaction transaction)
        {
            if (!HttpRuntime.UsingIntegratedPipeline)
            {
                return(Delegates.NoOp);
            }

            var httpContext = instrumentedMethodCall.MethodCall.MethodArguments.ExtractNotNullAs <HttpContext>(0);

            HttpContextActions.TransactionShutdown(agent, httpContext);

            var segment = agent.CastAsSegment(httpContext.Items[HttpContextActions.HttpContextSegmentKey] as ISegment);

            httpContext.Items[HttpContextActions.HttpContextSegmentKey]     = null;
            httpContext.Items[HttpContextActions.HttpContextSegmentTypeKey] = null;
            segment.End();
            agent.CurrentTransaction.End();

            return(Delegates.NoOp);
        }