Ejemplo n.º 1
0
        private static void SetLabel(IExecutionSegment executionSegment, object labelValue, string labelName)
        {
            switch (labelValue)
            {
            case string strVal:
                executionSegment.SetLabel(labelName, strVal);
                break;

            case int intVal:
                executionSegment.SetLabel(labelName, intVal);
                break;

            case double doubleVal:
                executionSegment.SetLabel(labelName, doubleVal);
                break;

            case long longVal:
                executionSegment.SetLabel(labelName, longVal);
                break;

            case decimal decimalValue:
                executionSegment.SetLabel(labelName, decimalValue);
                break;

            case bool boolValue:
                executionSegment.SetLabel(labelName, boolValue);
                break;

            default:
                throw new Exception("Unexpected Type");
            }
        }
 private void TryFixThreadsCount(IExecutionSegment span, double duration)
 {
     if (_Options?.LabelThreadsWhenDurationMs != null && _Options.LabelThreadsWhenDurationMs < duration)
     {
         ThreadPool.GetAvailableThreads(out int availableWT, out int availableIO);
         ThreadPool.GetMaxThreads(out int maxWT, out int maxIO);
         ThreadPool.GetMinThreads(out int minWT, out int minIO);
         span.SetLabel("Threads.Min.Workers", $"{minWT}");
         span.SetLabel("Threads.Min.IO", $"{minIO}");
         span.SetLabel("Threads.Available.Workers", $"{availableWT}");
         span.SetLabel("Threads.Available.IO", $"{availableIO}");
         span.SetLabel("Threads.Uses.Workers", $"{maxWT - availableWT}");
         span.SetLabel("Threads.Uses.IO", $"{maxIO - availableIO}");
     }
 }