Posts

Showing posts with the label metrics

.NET Metrics

Image
Introduction I recently posted about OpenTelemetry , and I mentioned metrics there, as it's an important part of observability . On this post I will dig a bit more about metrics, what they are and how they are used by .NET and ASP.NET Core. Very important, these definitions match the observability/ OpenTelemetry  standard, specifically, the Metrics API , and are designed to work together. Creating Metrics There are different kinds of metrics, and they are all usually created from the  Meter  class, part of the .NET System.Diagnostics.Metrics API. A  Meter  has a name ( Name ), an optional scope ( Scope ), an optional version ( Version ), and some optional tags ( Tags ), all unchangeable and initialised at constructor time, except tags. Besides this, it has build methods for all supported meters/instrument types. It can be constructed directly: var meter = new Meter("Some.Meter", version: "1.0.0"); The  Meter  class is disposable , so make sure you dis...