public override void Intercept(IInvocation invocation)
        {
            ZombieLoggingInfo info = new ZombieLoggingInfo();

            info.Class        = invocation.TargetType.FullName;
            info.MethodName   = invocation.Method.Name + " <S>";
            info.ZombieItSelf = GetZombieSightingFromArguments(invocation);

            var sw = Stopwatch.StartNew();

            Logger.Debug(info);

            invocation.Proceed();
            sw.Stop();
            info.Duration   = sw.Elapsed.Milliseconds;
            info.MethodName = invocation.Method.Name + " <F>";
            Logger.Debug(info);
        }
Пример #2
0
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            string correlationId = "N/A";

            if (request.Headers.Contains("BGT-CorrelationId"))
            {
                correlationId = request.Headers.GetValues("BGT-CorrelationId").First();
            }
            else if (!request.Properties.ContainsKey("BGT-CorrelationId"))
            {
                correlationId = Guid.NewGuid().ToString();
            }

            request.Properties["BGT-CorrelationId"] = correlationId;
            log4net.LogicalThreadContext.Properties["BGT-CorrelationId"] = correlationId;

            Stopwatch duration = Stopwatch.StartNew();

            ZombieLoggingInfo info = new ZombieLoggingInfo();

            info.Uri = request.RequestUri.AbsoluteUri + " <S>";

            _logger.Debug(info);

            var ret = base.SendAsync(request, cancellationToken);

            ret.ContinueWith(response =>
            {
                duration.Stop();
                info.Duration = (int)duration.ElapsedMilliseconds;
                info.Uri      = request.RequestUri.AbsoluteUri + " <F>";
                _logger.Debug(info);
            }, cancellationToken);

            return(ret);
        }