Beispiel #1
0
        private void MyTaskMethod(int myref)
        {
            var random = new Random();
            var delay  = random.Next(3000, 10000);

            //_logger.LogInformation($"{_httpContextAccessor.HttpContext.TraceIdentifier}:{myref} Random delay: {delay}ms");
            _logger.LogInformation($"{_traceIdentifierService.Get()}:{myref} Random delay: {delay}ms");

            var stopWatch = Stopwatch.StartNew();

            stopWatch.Start();
            Task.Delay(delay).Wait();
            stopWatch.Stop();

            //_logger.LogInformation($"{_httpContextAccessor.HttpContext.TraceIdentifier}:{myref} Finished delay in {stopWatch.Elapsed.TotalMilliseconds}ms");
            _logger.LogInformation($"{_traceIdentifierService.Get()}:{myref} Finished delay in {stopWatch.Elapsed.TotalMilliseconds}ms");
        }
Beispiel #2
0
        public IEnumerable <string> Get()
        {
            int myref = new Random().Next(0, 1000);

            //_logger.LogInformation($"{_httpContextAccessor.HttpContext.TraceIdentifier}:{myref} Starting request...");
            _logger.LogInformation($"{_traceIdentifierService.Get()}:{myref} Starting request...");

            var stopWatch = Stopwatch.StartNew();

            stopWatch.Start();
            _someService.LongRunningAsync(myref);
            stopWatch.Stop();

            //_logger.LogInformation($"{_httpContextAccessor.HttpContext.TraceIdentifier}:{myref} LongRunningAsync finished in {stopWatch.Elapsed.TotalMilliseconds}ms.");
            _logger.LogInformation($"{_traceIdentifierService.Get()}:{myref} LongRunningAsync finished in {stopWatch.Elapsed.TotalMilliseconds}ms.");

            //_logger.LogInformation($"{_httpContextAccessor.HttpContext.TraceIdentifier}:{myref} Finishing request...");
            _logger.LogInformation($"{_traceIdentifierService.Get()}:{myref} Finishing request...");

            return(new string[] { "value1", "value2" });
        }