728x90
728x170

1. 콘솔앱 생성
2. 아래와 같이 매트릭이 수집될수 있도록 코드 처리

using System.Diagnostics.Metrics;
class Program
{
    static Meter meter = new Meter("HatStore", "1.0.0");
    static Counter<int> hatsSold = meter.CreateCounter<int>("hats-sold");

    static void Main(string[] args)
    {
        Console.WriteLine("Press any key to exit");
        while (!Console.KeyAvailable)
        {
            // Pretend our store has a transaction each second that sells 4 hats
            Thread.Sleep(1000);
            hatsSold.Add(4);
        }
    }
}

3. dotnet-counters 설치

dotnet tool update -g dotnet-counters


4. ps 명령어로 processid 알아내기

dotnet-counters ps

5. processid 기준 HatStore 매트릭 모니터링 하기

dotnet-counters monitor -p 4712 HatStore

6. processid 기준 런타임 매트릭 모니터링하기

dotnet-counters monitor -p 7412 System.Runtime

[Source]
https://github.com/kei-soft/MetricTestConsoleApp

 

GitHub - kei-soft/MetricTestConsoleApp

Contribute to kei-soft/MetricTestConsoleApp development by creating an account on GitHub.

github.com


참고
https://learn.microsoft.com/ko-kr/dotnet/core/diagnostics/metrics-collection

 

메트릭 수집 - .NET

.NET 애플리케이션에서 메트릭을 수집하는 자습서

learn.microsoft.com

 

728x90
그리드형
Posted by kjun
,