예제 #1
0
 /// <nodoc />
 public static Task <GetStatsResult> GetStatsAsync(
     this Tracer tracer,
     OperationContext context,
     Func <Task <GetStatsResult> > func)
 {
     return(GetStatsCall <Tracer> .RunAsync(tracer, context, func));
 }
예제 #2
0
        /// <summary>
        ///     Run the call.
        /// </summary>
        public static async Task <GetStatsResult> RunAsync(TTracer tracer, OperationContext context, Func <Task <GetStatsResult> > funcAsync)
        {
            using (var call = new GetStatsCall <TTracer>(tracer, context))
            {
                var result = await call.RunAsync(funcAsync);

                if (result)
                {
                    var stats = new CounterSet();

                    stats.Add("CriticalErrors", tracer.NumberOfCriticalErrors);
                    stats.Add("RecoverableErrors", tracer.NumberOfRecoverableErrors);
                    result.CounterSet.Merge(stats, $"{tracer.GetType().Name}.{tracer.Name}.ErrorStats.");
                }

                return(result);
            }
        }