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);
        }
Ejemplo 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);
        }
                // 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;
                }
        public void OnAsyncTaskEnded(object sender, AsyncTaskEndedEventArgs args)
        {
            if (_startTimestampTicks == 0)
            {
                throw new InvalidOperationException("OnAsyncEventStarted was not invoked");
            }

            long endTimestampTicks = _timeSource.GetTimestampTicks();
            long startTimestampUs  = _timeSource.ConvertTicksToUs(_startTimestampTicks);
            long durationUs        = _timeSource.GetDurationUs(_startTimestampTicks, endTimestampTicks);
            int  threadId          = Thread.CurrentThread.ManagedThreadId;

            _tracingLogger.TraceEvent(args.CallerName, EventType.Async, args.CallerType, durationUs,
                                      startTimestampUs, threadId);
            _startTimestampTicks = 0;
        }