Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        public void Send(Action actionToTime, string statName)
        {
            var stopwatch = StopwatchFactory.Get();

            try
            {
                stopwatch.Start();
                actionToTime();
            }
            finally
            {
                stopwatch.Stop();
                Send <Timing>(statName, stopwatch.ElapsedMilliseconds());
            }
        }
Exemplo n.º 4
0
        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());
                }
            }
        }
Exemplo n.º 5
0
        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);
                }
            }
        }
Exemplo n.º 6
0
        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);
                }
            }
        }
Exemplo n.º 7
0
        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);
                }
            }
        }