Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Console App

I’m adding meters and such to a console app

Instrumentation

I started with just using the metrics for a counter in a simple console app working through the dotnet docs.

using System.Diagnostics.Metrics;

Meter s_meter = new Meter("HatCo.HatStore", "0.1.0");
Counter<int> s_hatsSold = s_meter.CreateCounter<int>("hats-sold");

Console.WriteLine("Press any key to exit");
while (!Console.KeyAvailable)
{
    Thread.Sleep(1000);
    s_hatsSold.Add(4);
}

And used the commands, to watch the information…

dotnet run to start the process.

dotnet counters ps to find the process ID

dotnet counters monitor --process-id 33172 HatCo.HatStore to monitor the counter

NOTE: The HatCo.HatStore references the meter I wanted to monitor.

Collection with Promethus

Collection with