linkedin / rest.li

Rest.li is a REST+JSON framework for building robust, scalable service architectures using dynamic discovery and simple asynchronous APIs.
rest.li
Other
2.51k stars 546 forks source link

Refactor DNS metrics for the `HttpNettyClient` to be easier to use. #853

Closed jpstewart closed 2 years ago

jpstewart commented 2 years ago

The current model requires injecting the HttpNettyClient into a JMX MBean. This doesn't work well with the current pattern of using the client, since the client type is abstracted and multiple clients could be created, resulting in a need to manage multiple MBeans even though the DNS resolution logic is shared globally.

This change lets the MBean itself hold the stats, and the Netty client will call back to it to increment the counters. This way when the HttpClientFactory is created we can provide it with a single MBean to track DNS across all clients, and the factory can handle injecting it properly into an applicable client instances it creates.