You need to enable JavaScript to run this app. Quarkus 1.13.2中quarkus-smallrye-opentracing如何禁用remoteReporter
优惠活动
大模型
产品
解决方案
定价
更多

Quarkus 1.13.2中quarkus-smallrye-opentracing如何禁用remoteReporter

解决方案

前置说明

Quarkus 1.13.2.Final 版本自带的 Jaeger 扩展不存在 quarkus.jaeger.sender-factory 配置项,该配置为 Quarkus 2.x 及以上版本新增特性,因此配置后不生效属于正常情况。

以下两种方案均可实现保留链路生成能力、禁用Jaeger客户端远程上报的需求,适配Istio接管链路上报的场景:

方案1:配置文件修改(推荐)

直接在 application.properties 中添加如下配置即可:

# 配置Jaeger Sender为无操作实现,不会向agent发送任何链路数据
quarkus.jaeger.sender.endpoint=noop://
# 可选:关闭span本地日志打印,不需要可删除该行
quarkus.jaeger.reporter.log-spans=false

方案2:自定义Tracer实例(极端场景备用)

如果配置方式不生效,可以手动覆盖Quarkus默认生成的Tracer Bean,强制使用无操作上报实现:

  1. 确保pom.xml中已引入核心依赖(已引入可跳过)
<dependency>
    <groupId>io.jaegertracing</groupId>
    <artifactId>jaeger-core</artifactId>
</dependency>
<dependency>
    <groupId>io.opentracing</groupId>
    <artifactId>opentracing-api</artifactId>
</dependency>
  1. 新增自定义Tracer配置类
import io.jaegertracing.Configuration;
import io.jaegertracing.internal.reporters.NoopReporter;
import io.jaegertracing.internal.samplers.ConstSampler;
import io.opentracing.Tracer;
import javax.enterprise.inject.Produces;
import javax.inject.Singleton;

public class CustomJaegerConfig {

    @Produces
    @Singleton
    public Tracer jaegerTracer() {
        return new Configuration("替换为你的实际服务名")
                // 保留采样逻辑,不影响链路生成
                .withSampler(new ConstSampler(true))
                // 使用无操作Reporter,完全关闭客户端上报
                .withReporter(new NoopReporter())
                .getTracer();
    }
}

内容的提问来源于stack exchange,提问作者LeoKao

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.21 09:57:03