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); }
public void StopTrace() { if (_currentMethodTracer != null) { _currentMethodTracer.StopTrace(); if (!_currentMethodTracer.IsActive()) { var methodTraceResult = _currentMethodTracer.GetTraceResult(); ThreadTraceResult.AddMethodTraceResult(methodTraceResult); _currentMethodTracer = null; } } else { throw new InvalidOperationException(); } }
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); } }