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);
        }
Beispiel #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);
        }
        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;
        }