我们在生产环境中使用Spring Cloud Gateway,并试图公开Netty连接池指标。我找不到在网关中启用Netty连接指标的配置。我认为公开指标的唯一方法是覆盖GatewayHttpClient类中的ConnectionProvider。是否有其他方法可用于公开Netty度量,而无需覆盖网关内部代码?
发布于 2021-05-17 08:40:03
这是因为Spring Cloud Gateway创建的HttpClient没有启用度量,您可以这样修改HttpClient:
@Component
public class HttpClientConfig implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof HttpClient) {
HttpClient client = (HttpClient) bean;
return client.metrics(true, s -> s);
}
return bean;
}
}https://stackoverflow.com/questions/67483803
复制相似问题