public void OnAsyncTaskStarted(object sender, EventArgs args)
 {
     if (_startTimestampTicks != 0)
     {
         throw new InvalidOperationException("OnAsyncTaskStarted was already invoked");
     }
     _startTimestampTicks = _timeSource.GetTimestampTicks();
 }
Esempio n. 2
0
        public void Intercept(IInvocation invocation)
        {
            long startTicks = _timeSource.GetTimestampTicks();

            // TODO: catch and record exceptions
            invocation.Proceed();
            long endTicks = _timeSource.GetTimestampTicks();
            int  tid      = Thread.CurrentThread.ManagedThreadId;

            _traceLogger.TraceEvent(invocation.Method.Name, EventType.Sync, invocation.TargetType,
                                    _timeSource.GetDurationUs(startTicks, endTicks),
                                    _timeSource.ConvertTicksToUs(startTicks), tid);
        }
 internal Step(StepsRecorder stepsRecorder, ITimeSource timeSource,
               ExpressionEvaluationEngine engine)
 {
     _startTicks    = timeSource.GetTimestampTicks();
     _stepsRecorder = stepsRecorder;
     _timeSource    = timeSource;
     _engine        = engine;
     _finalized     = false;
 }
        public override TResponse BlockingUnaryCall <TRequest, TResponse>(TRequest request,
                                                                          ClientInterceptorContext <TRequest, TResponse> context,
                                                                          BlockingUnaryCallContinuation <TRequest, TResponse> continuation)
        {
            long startTicks = timeSource.GetTimestampTicks();
            var  tid        = Thread.CurrentThread.ManagedThreadId;

            var response = continuation(request, context);

            long endTicks = timeSource.GetTimestampTicks();

            traceLogger.TraceEvent(
                context.Method.Name,
                EventType.Sync,
                request.GetType(),
                timeSource.GetDurationUs(startTicks, endTicks),
                timeSource.ConvertTicksToUs(startTicks),
                tid);

            return(response);
        }
                // Step finalization for LLDB and LLDB_VARIABLE_PATH engines.
                public void Finalize(LLDBErrorCode lldbErrorCode)
                {
                    long endTicks = _timeSource.GetTimestampTicks();

                    if (_engine != ExpressionEvaluationEngine.LLDB && _engine !=
                        ExpressionEvaluationEngine.LLDB_VARIABLE_PATH)
                    {
                        throw new ArgumentException(
                                  $"Engine {_engine} is incompatible with LLDBErrorCode " +
                                  $"({lldbErrorCode}). Check the parameters for the invoked method.");
                    }

                    if (_finalized)
                    {
                        throw new InvalidOperationException("Object is already finalized");
                    }

                    var batchParams = new ExpressionEvaluationStepBatchParams(
                        _engine, lldbErrorCode, _timeSource.GetDurationUs(_startTicks, endTicks));

                    _stepsRecorder.AddStep(batchParams);

                    _finalized = true;
                }