Named meter registration
Use named registration when you want multiple logical meter sources in the same application and resolve them explicitly with keyed services.
Register a named meter
Section titled “Register a named meter”var services = new ServiceCollection();
services.AddNamedMeter("orders");This registers:
- keyed
System.Diagnostics.Metrics.Meterwith the nameorders - keyed
IMeter<T>that resolves to that same namedMeter
Resolve the named meter in consumers
Section titled “Resolve the named meter in consumers”public class OrderService([FromKeyedServices("orders")] IMeter<OrderService> meter){}IMeter<T> remains available as a non-keyed service as well, where the underlying meter name defaults to the type name.