Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何从执行器/指标端点中排除Hystrix指标?_Spring_Spring Boot_Spring Cloud_Hystrix_Spring Boot Actuator - Fatal编程技术网

Spring 如何从执行器/指标端点中排除Hystrix指标?

Spring 如何从执行器/指标端点中排除Hystrix指标?,spring,spring-boot,spring-cloud,hystrix,spring-boot-actuator,Spring,Spring Boot,Spring Cloud,Hystrix,Spring Boot Actuator,我有一个spring boot应用程序,启用了执行器和Hystrix。 Spring启动版本:1.3.1.0版本 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> &

我有一个spring boot应用程序,启用了执行器和Hystrix。
Spring启动版本:1.3.1.0版本

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
问题:
如何从
/metrics
端点中完全排除hystrix指标


更新1
我试图通过以下方法排除伺服测量和观众测量:

(一)

(二)

但两者都没有达到预期效果。

这是创建并修复的。在快照中,您现在可以设置以下内容:
hystrix.metrics.enabled=false

如果您不需要任何其他指标,更好的解决方案是创建自己的MetricsRegistry。这样,任何其他未来的代码更改(添加更多具有更多内置度量的JAR)都不会影响

@Configuration
public class MetricsConfiguration {

  private MetricRegistry metricRegistry;

  MetricsConfiguration() {
    //avoid other metrics already registered
    metricRegistry = new MetricRegistry();
  }

}

注意:创建MetricRegistry类型的@Bean没有帮助,由于Spring自动配置将使用此Bean对象,而不是MetricsDropwizardAutoConfiguration.java中的
MetricsRegistry对象,因此目前无法排除它们,除非您从依赖项中排除
com.netflix.hystrix:hystrix metrics事件流,这也将导致
/hystrix.stream
“也要停止工作。”斯宾塞·吉布感谢您的澄清。太糟糕了。。。这可能值得一个功能请求…完成,看看我的新答案。哇,太快了!万分感谢!在Spring代码/配置中有效地设置这个参数不是很简单。但将其设置为系统变量效果很好。
@EnableAutoConfiguration(exclude={ServoMetricsAutoConfiguration.class,
 SpectatorMetricsAutoConfiguration.class} )
@SpringBootApplication(exclude={ServoMetricServices.class, SpectatorMetricServices.class})
@Configuration
public class MetricsConfiguration {

  private MetricRegistry metricRegistry;

  MetricsConfiguration() {
    //avoid other metrics already registered
    metricRegistry = new MetricRegistry();
  }

}