You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "houhuacheng (GitHub)" <gi...@apache.org> on 2019/03/08 09:47:21 UTC
[GitHub] [incubator-dubbo-spring-boot-project] houhuacheng commented on issue #355: dubbo filter 配置不生效,最好整合日志slf4j,能有个像springcloud一样的traceId 日志追踪链
springboot:2.0.5.RELEASE
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
1.继承接口com.alibaba.dubbo.rpc.Filter实现public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException 方法
加上@Activate注解
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
logger.info("111111111111111111111111");
String tarceId = MDC.get(TraceConstant.TraceId);
Map<String, String> attachments = invocation.getAttachments();
attachments.put(TraceConstant.TraceId, tarceId);
Result result=invoker.invoke(invocation);
logger.info("222222222222222222222222");
return result;
}
2.配置文件修改
在resources目录下添加纯文本文件META-INF/dubbo/com.alibaba.dubbo.rpc.Filter
例如:traceIdFilter=com.xxx.TraceIdFilter
3.使用:
application.properties 配置 添加
dubbo.provider.filter =traceIdFilter 无效 不能注入filter 不能打印数字
@Reference(check = false,filter = traceIdFilter)依然无效
[ Full content available at: https://github.com/apache/incubator-dubbo-spring-boot-project/issues/355 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org