public async Task SendAsync(Action actionToTime, string statName, double sampleRate = 1.0, string[] tags = null) { var stopwatch = StopwatchFactory.Get(); try { stopwatch.Start(); actionToTime(); } finally { stopwatch.Stop(); await SendAsync <Timing, int>(statName, stopwatch.ElapsedMilliseconds(), sampleRate, tags).ConfigureAwait(false); } }
public void Send(Action actionToTime, string statName, double sampleRate = 1.0, string[] tags = null) { var stopwatch = StopwatchFactory.Get(); try { stopwatch.Start(); actionToTime(); } finally { stopwatch.Stop(); Send <Timing, int>(statName, stopwatch.ElapsedMilliseconds(), sampleRate, tags); } }
public void Send(Action actionToTime, string statName) { var stopwatch = StopwatchFactory.Get(); try { stopwatch.Start(); actionToTime(); } finally { stopwatch.Stop(); Send <Timing>(statName, stopwatch.ElapsedMilliseconds()); } }
public void Send(Action actionToTime, string statName, double sampleRate = 1) { var stopwatch = StopwatchFactory.Get(); try { stopwatch.Start(); actionToTime(); } finally { stopwatch.Stop(); if (RandomGenerator.ShouldSend(sampleRate)) { Send <Timing>(statName, stopwatch.ElapsedMilliseconds()); } } }
public void Add(Action actionToTime, string statName, double sampleRate = 1, IDictionary <String, String> dimensions = null) { var stopwatch = StopwatchFactory.Get(); try { stopwatch.Start(); actionToTime(); } finally { stopwatch.Stop(); if (RandomGenerator.ShouldSend(sampleRate)) { Add <Timing>(statName, stopwatch.ElapsedMilliseconds(), dimensions); } } }
private void HandleTiming(Action actionToTime, string statName, double sampleRate, Action <string, int> actionToStore) { var stopwatch = StopwatchFactory.Get(); try { stopwatch.Start(); actionToTime(); } finally { stopwatch.Stop(); if (RandomGenerator.ShouldSend(sampleRate)) { actionToStore(statName, stopwatch.ElapsedMilliseconds); } } }
public async Task SendAsync(Func <Task> actionToTime, ReadOnlyMemory <char> statName, double sampleRate = 1) { var stopwatch = StopwatchFactory.Get(); try { stopwatch.Start(); await actionToTime().ConfigureAwait(false); } finally { stopwatch.Stop(); if (RandomGenerator.ShouldSend(sampleRate)) { await SendAsync <Timing>(statName.Span, stopwatch.ElapsedMilliseconds).ConfigureAwait(false); } } }