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
참고
https://learn.microsoft.com/ko-kr/dotnet/core/diagnostics/metrics-collection
728x90
그리드형
'C#' 카테고리의 다른 글
[C#/Metric] Grafana 대시보드에 메트릭 표시하기 (0) | 2023.01.12 |
---|---|
[C#/Metric] 매트릭 수집 - Prometheus, OpenTelemetry 이용하여 매트릭 보기 (0) | 2023.01.11 |
[C#] Dapper.Net ebook (pdf) & 참고 사이트 (0) | 2022.12.12 |
[C#] Array.ConvertAll - 배열요소 모두 타입 변환하기 (0) | 2022.10.18 |
[C#] WebView2 에 html source 처리하는 방법 (0) | 2022.10.11 |