Create ObservableGauge and UpDownCounter instruments in .NET 8 metrics

Опубликовано: 15 Октябрь 2024
на канале: Authorised Territory
249
10

Authorised Territory code examples - This #dotnet C# #tutorial shows how to create meters with ObservableGauge and UpDownCounter instruments in .NET 8.
First, we create minimal API project and implement meter with ObservableGauge. Next we add an endpoint to demonstrate the new meter and by running dotnet-counters tool we see it in action.
Finally, we create a custom metric to demonstrate UpDownCounter instrument with two endpoints. Using endpoint explorer in Visual Studio 2022 to generate requests we see the metrics reporting in dotnet-counters.