示例#1
0
        public static T LoggingWrapper <T>(LocatorServiceClientAdapter glsClientAdapter, string parameter, string connectionId, Func <T> method) where T : ResponseBase
        {
            string ipAddress     = glsClientAdapter.ResolveEndpointToIpAddress(false);
            string diagnostics   = string.Empty;
            string transactionId = string.Empty;
            string text          = string.Empty;
            int    tickCount     = Environment.TickCount;
            T      result;

            try
            {
                GLSLogger.FaultInjectionTrace();
                result        = method();
                diagnostics   = result.Diagnostics;
                transactionId = result.TransactionID;
            }
            catch (Exception ex)
            {
                text      = ex.Message;
                ipAddress = glsClientAdapter.ResolveEndpointToIpAddress(true);
                throw;
            }
            finally
            {
                int    num        = Environment.TickCount - tickCount;
                string resultCode = string.IsNullOrEmpty(text) ? "Success" : "Exception";
                GLSLogger.BeginAppend(method.Method.Name, parameter, ipAddress, resultCode, null, (long)num, text, transactionId, connectionId, diagnostics);
                bool   isRead;
                string apiName = GLSLogger.ApiNameFromReturnType <T>(out isRead);
                ADProviderPerf.UpdateGlsCallLatency(apiName, isRead, num, string.IsNullOrEmpty(text));
            }
            return(result);
        }
示例#2
0
        public static void LogResponse(GlsLoggerContext context, GLSLogger.StatusCode statusCode, ResponseBase response, GlsRawResponse rawResponse)
        {
            int    num = Environment.TickCount - context.TickStart;
            string resultCode;

            switch (statusCode)
            {
            case GLSLogger.StatusCode.Found:
                resultCode = "Found";
                break;

            case GLSLogger.StatusCode.NotFound:
                resultCode = "NotFound";
                break;

            case GLSLogger.StatusCode.WriteSuccess:
                resultCode = "Success";
                break;

            default:
                throw new ArgumentException("statusCode");
            }
            GLSLogger.BeginAppend(context.MethodName, context.ParameterValue, context.ResolveEndpointToIpAddress(false), resultCode, rawResponse, (long)num, string.Empty, response.TransactionID, context.ConnectionId, response.Diagnostics);
            ADProviderPerf.UpdateGlsCallLatency(context.MethodName, context.IsRead, num, true);
        }
示例#3
0
        public static void LogException(GlsLoggerContext context, Exception ex)
        {
            int        num        = Environment.TickCount - context.TickStart;
            StackTrace stackTrace = new StackTrace(false);

            GLSLogger.BeginAppend(context.MethodName, context.ParameterValue, context.ResolveEndpointToIpAddress(true), "Exception", null, (long)num, ex.Message + stackTrace.ToString(), context.RequestTrackingGuid.ToString(), context.ConnectionId, string.Empty);
            ADProviderPerf.UpdateGlsCallLatency(context.MethodName, context.IsRead, num, false);
        }