Ejemplo n.º 1
0
        private static void Set(string label, ThreadCounter threadCounter, ClientContext clientContext, RequestLogger requestLogger, ThreadContext.ExecuteDelegate executeDelegate)
        {
            string text = (clientContext != null) ? clientContext.IdentityForFilteredTracing : "none";
            RequestStatisticsForThread requestStatisticsForThread = RequestStatisticsForThread.Begin();

            threadCounter.Increment();
            ThreadContext.Tracer.TraceDebug <string, string, string>(0L, "{0}: Thread entered {1}. MessageId={2}", text, label, (clientContext != null) ? (clientContext.MessageId ?? "<null>") : "none");
            try
            {
                using (new ASTraceFilter(null, text))
                {
                    TraceContext.Set(text);
                    try
                    {
                        executeDelegate();
                    }
                    finally
                    {
                        TraceContext.Reset();
                    }
                }
            }
            finally
            {
                threadCounter.Decrement();
                RequestStatistics requestStatistics = requestStatisticsForThread.End(RequestStatisticsType.ThreadCPULongPole, label);
                if (requestStatistics != null && requestLogger != null)
                {
                    requestLogger.Add(requestStatistics);
                }
                ThreadContext.Tracer.TraceDebug <string, string>(0L, "{0}: Thread exited {1}", text, label);
            }
        }
Ejemplo n.º 2
0
        public static T Set <T>(string label, ThreadCounter threadCounter, ClientContext clientContext, RequestLogger requestLogger, ThreadContext.ExecuteDelegate <T> executeDelegate)
        {
            T result = default(T);

            ThreadContext.Set(label, threadCounter, clientContext, requestLogger, delegate()
            {
                result = executeDelegate();
            });
            return(result);
        }
Ejemplo n.º 3
0
 public Query(CasTraceEventType casTraceEventType, ThreadCounter threadCounter, ExPerformanceCounter currentRequestsCounter)
 {
     this.casTraceEventType      = casTraceEventType;
     this.threadCounter          = threadCounter;
     this.currentRequestsCounter = currentRequestsCounter;
     this.Timeout = Configuration.WebRequestTimeoutInSeconds;
     this.requestProcessingDeadline = DateTime.UtcNow + this.Timeout;
     this.queryPrepareDeadline      = this.requestProcessingDeadline;
     this.RequestLogger             = new RequestLogger();
     ConfigurationReader.Start(this.RequestLogger);
 }
Ejemplo n.º 4
0
 public static void SetWithExceptionHandling(string label, ThreadCounter threadCounter, ClientContext clientContext, RequestLogger requestLogger, ThreadContext.ExecuteDelegate executeDelegate)
 {
     ThreadContext.Set(label, threadCounter, clientContext, requestLogger, delegate()
     {
         try
         {
             GrayException.MapAndReportGrayExceptions(delegate()
             {
                 executeDelegate();
             });
         }
         catch (GrayException arg)
         {
             string arg2 = (clientContext != null) ? clientContext.IdentityForFilteredTracing : "none";
             ThreadContext.Tracer.TraceError <string, GrayException>(0L, "{0}: failed with exception: {1}", arg2, arg);
         }
     });
 }
Ejemplo n.º 5
0
 public Query(ClientContext clientContext, HttpResponse httpResponse, CasTraceEventType casTraceEventType, ThreadCounter threadCounter, ExPerformanceCounter currentRequestsCounter) : this(casTraceEventType, threadCounter, currentRequestsCounter)
 {
     this.ClientContext = clientContext;
     this.HttpResponse  = httpResponse;
 }