Esempio n. 1
0
        public async Task <IServiceRemotingResponseMessage> HandleRequestResponseAsync(
            IServiceRemotingRequestContext requestContext,
            IServiceRemotingRequestMessage requestMessage)
        {
            Dictionary <string, string> context = ExtractContextProperties(requestMessage);

            if (context == null)
            {
                return(await _innerHandler.HandleRequestResponseAsync(requestContext, requestMessage));
            }
            else
            {
                using (L.Context(context))
                {
                    return(await _innerHandler.HandleRequestResponseAsync(requestContext, requestMessage));
                }
            }
        }
        public async Task <IServiceRemotingResponseMessage> HandleRequestResponseAsync(
            IServiceRemotingRequestContext requestContext,
            IServiceRemotingRequestMessage requestMessage)
        {
            Dictionary <string, string> context = ExtractContextProperties(requestMessage);
            string methodName = MethodResolver.GetMethodName(requestMessage);

            Exception gex = null;

            using (L.Context(context))
            {
                using (var time = new TimeMeasure())
                {
                    try
                    {
                        return(await _innerHandler.HandleRequestResponseAsync(requestContext, requestMessage));
                    }
                    catch (Exception ex)
                    {
                        gex = ex;
                        throw;
                    }
                    finally
                    {
                        if (_raiseSummary != null)
                        {
                            var summary = new CallSummary(methodName, gex, time.ElapsedTicks);
                            _raiseSummary(summary);
                        }

                        _log.Request(methodName, time.ElapsedTicks, gex,
                                     context.ToDictionary(k => k.Key, v => (object)(v.Value)));
                    }
                }
            }
        }