Skip to content

Commit

Permalink
add gauges for process uptime & number of threads
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Margarintescu committed Sep 23, 2014
1 parent 98b80a8 commit 6224694
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Src/Metrics/PerfCounters/ThreadPoolMetrics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Threading;
using System;
using System.Diagnostics;
using System.Threading;

namespace Metrics.PerfCounters
{
Expand All @@ -14,6 +16,10 @@ public static void RegisterThreadPoolGauges(MetricsContext context)

context.Gauge("Thread Pool Max Threads", () => { int threads, ports; ThreadPool.GetMaxThreads(out threads, out ports); return threads; }, Unit.Threads);
context.Gauge("Thread Pool Max Completion Ports", () => { int threads, ports; ThreadPool.GetMaxThreads(out threads, out ports); return ports; }, Unit.Custom("Ports"));

var currentProcess = Process.GetCurrentProcess();
context.Gauge(currentProcess.ProcessName + " Uptime", () => (DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime()).TotalSeconds, Unit.Custom("Seconds"));
context.Gauge(currentProcess.ProcessName + " Threads", () => Process.GetCurrentProcess().Threads.Count, Unit.Threads);
}
}
}

0 comments on commit 6224694

Please sign in to comment.