コード例 #1
0
 public static T Timing <T>([NotNull] this IStatsDClient client, [NotNull, ItemNotNull] string[] keys, [NotNull] Func <T> action, [NotNull] out Stopwatch timer)
 {
     timer = Stopwatch.StartNew();
     try
     {
         return(action());
     }
     finally
     {
         timer.Stop();
         client.Timing(timer.ElapsedMilliseconds, sampleRate: 1.0, keys);
     }
 }
コード例 #2
0
        public static async Task <T> TimingAsync <T>([NotNull] this IStatsDClient client, [NotNull, ItemNotNull] string[] keys, [NotNull] Func <Task <T> > action)
        {
            var timer = Stopwatch.StartNew();

            try
            {
                return(await action().ConfigureAwait(false));
            }
            finally
            {
                timer.Stop();
                client.Timing(timer.ElapsedMilliseconds, sampleRate: 1.0, keys);
            }
        }
コード例 #3
0
 public static void Timing([NotNull] this IStatsDClient client, [NotNull] string key, long timing, double sampleRate = 1.0)
 {
     client.Timing(timing, sampleRate, key);
 }