【问题标题】:Exclude specific controllers from sleuth / brave to trace从侦探/勇敢者中排除特定控制器以进行追踪
【发布时间】:2019-10-14 18:24:41
【问题描述】:

我们在 Spring Boot 应用程序中使用了勇敢的 API。我们能够跟踪所有控制器和服务。但问题是我们在一些我们不想跟踪的控制器中得到跟踪,比如健康检查控制器。有没有办法在控制器中指定它,因为默认情况下它正在跟踪所有控制器。
我试过使用

spring:
  application:
    name: abc
  sleuth:
    enabled: "true"
    reporter:
      enabled: "true"
    sampler:
      probability: "1.0"
    instrument:
      web:
        skipPattern: (^status* | ^Status* | *status*)

spring:
  application:
    name: abc
  sleuth:
    enabled: "true"
    reporter:
      enabled: "true"
    sampler:
      probability: "1.0"
    web:
        skipPattern: (^status* | ^Status* | *status*)

但它没有工作。状态控制器

@RestController
public class StatusController {

  @Autowired
  public StatusController() {

  }

  @RequestMapping(value = "/status", method = RequestMethod.GET)
  public Boolean status() {
    return true;
  }
}

请帮忙。
谢谢

【问题讨论】:

    标签: spring-boot spring-cloud-sleuth zipkin


    【解决方案1】:

    *status* 不是有效的正则表达式。试试/status。您可以检查https://github.com/spring-cloud/spring-cloud-sleuth/blob/v2.1.4.RELEASE/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/SleuthWebProperties.java#L34 的默认值。此外,使用additionalSkipPattern 属性将您的自定义值附加到现有值可能更有意义。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-29
      • 1970-01-01
      • 2022-06-26
      • 1970-01-01
      • 2021-11-27
      • 1970-01-01
      • 2021-05-06
      相关资源
      最近更新 更多