Exemplo n.º 1
0
        /// <summary>
        /// ThreadPool Event
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        private Task ThreadPoolEventProfilerCallback(ThreadPoolEventStatistics arg)
        {
            // memo: send metrics to datadog or any favor you like.
            if (arg.Type == ThreadPoolStatisticType.ThreadPoolWorkerStartStop)
            {
                DatadogTracing.ThreadPoolEventWorker(arg.ThreadPoolWorker);
                _logger.LogInformation($"ThreadPoolStartStop ActiveWrokerThreads {arg.ThreadPoolWorker.ActiveWrokerThreads};");
            }
            else if (arg.Type == ThreadPoolStatisticType.ThreadPoolAdjustment)
            {
                DatadogTracing.ThreadPoolEventAdjustment(arg.ThreadPoolAdjustment);
                _logger.LogInformation($"ThreadAdjustment Reason {arg.ThreadPoolAdjustment.Reason}; NewWorkerThread {arg.ThreadPoolAdjustment.NewWorkerThreads}; AverageThrouput {arg.ThreadPoolAdjustment.AverageThrouput};");

                if (arg.ThreadPoolAdjustment.Reason == 0x07)
                {
                    // special handling for threadPool starvation. This is really critical for .NET (.NET Core) Apps.
                    DatadogTracing.ThreadPoolStarvationEventAdjustment(arg.ThreadPoolAdjustment);
                }
            }
            return(Task.CompletedTask);
        }