コード例 #1
0
        public async Task <ActionResult <string> > GetCalculatePi([FromQuery] int digits = 5)
        {
            try
            {
                log.LogInformation($"Starting GetCalculatePi with {digits} digits.");
                var pi = string.Empty;

                var sw = Stopwatch.StartNew();
                pi = CalculatePi(digits);
                sw.Stop();


                await service.LogMetrics("PiCalculatorAPI", "ResponseTimes", Convert.ToInt32(sw.ElapsedMilliseconds));

                log.LogInformation($"Finished GetCalculatePi in {sw.ElapsedMilliseconds} ms.");

                return(pi);
            }
            catch (Exception ex)
            {
                log.LogError(ex, $"GetCalculatePi failed beacuse of: {ex.Message}");
                throw;
            }
        }