예제 #1
0
 public override void Call(RpcServerContext ctx)
 {
     if (RatePerSecond != null)
     {
         try {
             if (RatePerSecond != null)
             {
                 RatePerSecond.Increment();
                 Concurrent.Increment();
             }
             Method.Invoke(Service, new object[] { new RpcBatchServerContext(ctx) });
         } catch (Exception ex) {
             ctx.ReturnError(RpcErrorCode.ServerError, ex);
         } finally {
             Concurrent.Decrement();
         }
     }
     else
     {
         try {
             Method.Invoke(Service, new object[] { new RpcBatchServerContext(ctx) });
         } catch (Exception ex) {
             ctx.ReturnError(RpcErrorCode.ServerError, ex);
         }
     }
 }
예제 #2
0
        public void Observe(Action action)
        {
            var stopwatch = Stopwatch.StartNew();

            InPerSec.Increment();
            try
            {
                action();
            }
            finally
            {
                if (System.Runtime.InteropServices.Marshal.GetExceptionCode() != 0)
                {
                    ErrorsPerSec.Increment();
                }
                PendingTimeAverage.Increment(stopwatch);
                OutPerSec.Increment();
            }
        }