Posts

.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...

Old Blog Inaccessible

My original blog at weblogs.asp.net ,  https://weblogs.asp.net/ricardoperes , has been experiencing some severe issues as of last week, as the result, it is currently inaccessible. I was told by Neudesic that they are working on it, and no loss is expected. Apologies to all readers, but it's beyond me. Fingers crossed! Update: it's back again ! Update 2: it seems that it's no longer possible to update the old blog or add any contents to it, or even log in, so please do not add any contents as I will be unable to reply to them.

ASP.NET Core Extension Points - MVC

Introduction This is post #2 on my series of posts on ASP.NET Core extensibility. The first one is this one , on the core extension points. This time, I'm going to focus on extensibility that is specific to MVC . I'm covering here: Controller factories and activators Action invokers, action invoker factories and action invoker providers Action constraints and action contraint factories Value providers and value provider factories Input and output formatters Output cache Controller Factories and Activators A controller factory is what creates a controller instance and also takes care of releasing (disposing of) it. A controller activator does similar things, even the methods they expose are very similar, as we can see it from the controller factory  IControllerFactory  and the controller activator  IControllerActivator  interfaces. As it is, the default controller factory class,  DefaultControllerFactory , receives a controller activator from Dependency Injection...

ASP.NET Core Extension Points - Core

Introduction This will be a long series of post about some of the ASP.NET Core extensibility points. By this, I mean any feature of ASP.NET Core that can be replaced/augmented by adding custom code, or switching to a different existing option. I will mention each extension point, how to change it, and some of its typical use cases. This will be split into different posts, and the structure is likely to be: ASP.NET Core itself (this one) MVC  only MVC  and  Minimal APIs : things that are relevant to both MVC  and  Razor Pages : same here Razor Pages  only Let's start first with the basics, functionality that exists regardless of MVC or Minimal APIs or Razor Pages . I'm going to cover: Hosts and servers Dependency Injection Middleware and middleware factories JSON and XML serialisation File providers Data protection and data protection providers Cryptography Session store Hosts and Servers A host is what executes a server to, you know, serve HTTP reques...