我们可以使用 sleuth、Spring Boot 来增加仅对错误/异常跨度进行采样的概率吗

发布于 2025-01-13 06:03:27 字数 101 浏览 2 评论 0原文

我想仅增加对包含错误或异常的那些范围的采样。 如果可能的话该怎么做?

我正在使用 Spring boot(2.2+)、sleuth(2.2+) 和 zipkin(2.2+)。

I want to increase sampling of only those spans which contains error or exception.
If that's possible then how to do that?

I'm using Spring boot(2.2+), sleuth(2.2+) and zipkin(2.2+).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲鸠 2025-01-20 06:03:28

如果您使用的是 Brave(默认),您可以注册一个类型为 brave.handler.SpanHandler 的 bean,并在方法 end 中返回 false 如果 < code>MutableSpan 有任何错误。

@Component
class ExceptionCheckingSpanHandler extends brave.handler.SpanHandler {

  @Override
  public boolean end(TraceContext context, MutableSpan span, Cause cause) {
    return span.error() != null;
  }

}

If you're using Brave (which is the default) you can register a bean of type brave.handler.SpanHandler and over there in the method end return false if the MutableSpan had any errors.

@Component
class ExceptionCheckingSpanHandler extends brave.handler.SpanHandler {

  @Override
  public boolean end(TraceContext context, MutableSpan span, Cause cause) {
    return span.error() != null;
  }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文