icerpc-csharp icon indicating copy to clipboard operation
icerpc-csharp copied to clipboard

Client factory decorators for logging and metrics

Open bentoi opened this issue 2 years ago • 2 comments

From a DI perspective, I think it would be much cleaner to replace the ILogger? logger client connection or connection cache arguments with an IClientProtocolConnectionFactory argument. We'd support a logger and a metrics factory decorator and a default factory that provides both logging and metrics.

Our DI extension, could create these decorators if a logger is registered or if services.AddMetrics() is called.

We could consider doing the same for Server if we add IProtocolConnectionListenerFactory.

bentoi avatar Jan 19 '23 09:01 bentoi

We're talking about constructor parameters for ClientConnection and ConnectionCache here.

I find ILogger? much more user-friendly and expected than IClientProtocolConnectionFactory.

Removing ILogger? would also prevent us from using the logger for logging some errors. See #2351.

bernardnormier avatar Jan 19 '23 14:01 bernardnormier

We can keep an ILogger convenience constructor that sets up a decorated client connection factory but I think we should provide the option to let the application provide an IClientProtocolConnectionFactory.

It's the DI way, it allows the application to implement custom logging/metrics, it allows to disable our metrics/logger decorators.

bentoi avatar Jan 20 '23 12:01 bentoi