Exemple #1
0
        public void StartTrace()
        {
            var stackTrace = new StackTrace(true);
            var frame      = stackTrace.GetFrame(2);
            var method     = frame.GetMethod();
            var methodName = method.Name;
            var className  = method.DeclaringType.FullName;

            if (_currentMethodTracer == null)
            {
                _currentMethodTracer = new MethodTracer();
            }
            _currentMethodTracer.StartTrace(className, methodName);
        }
Exemple #2
0
 public void StopTrace()
 {
     if (_currentMethodTracer != null)
     {
         _currentMethodTracer.StopTrace();
         if (!_currentMethodTracer.IsActive())
         {
             var methodTraceResult = _currentMethodTracer.GetTraceResult();
             ThreadTraceResult.AddMethodTraceResult(methodTraceResult);
             _currentMethodTracer = null;
         }
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Exemple #3
0
 public void StartTrace(string className, string methodName)
 {
     if (!_active)
     {
         _active            = true;
         _startTime         = DateTimeOffset.Now.ToUnixTimeMilliseconds();
         _methodTraceResult = new MethodTraceResult(className, methodName);
     }
     else
     {
         MethodTracer innerMethodTracer;
         if (_innerMethodTracers.Count == 0)
         {
             innerMethodTracer = new MethodTracer();
             _innerMethodTracers.Push(innerMethodTracer);
         }
         else
         {
             innerMethodTracer = _innerMethodTracers.Peek();
         }
         innerMethodTracer.StartTrace(className, methodName);
     }
 }