You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/07/17 00:47:24 UTC
[GitHub] 34176470 opened a new issue #2089: Dubbo自扩展Filter和ExtensionFactory在阿里云EDAS环境下无效果
34176470 opened a new issue #2089: Dubbo自扩展Filter和ExtensionFactory在阿里云EDAS环境下无效果
URL: https://github.com/apache/incubator-dubbo/issues/2089
根据dubbo的Filter和ExtensionFactory扩展方式,自己扩展了一个Filter和ExtensionFactory
`@activate(group = {Constants.PROVIDER, Constants.CONSUMER}, value = "tracing")
public final class TracingFilter implements Filter {
private static Logger logger = LoggerFactory.getLogger(TracingFilter.class);
Tracer tracer;
TraceContext.Extractor<Map<String, String>> extractor;
TraceContext.Injector<Map<String, String>> injector;
public void setTracing(Tracing tracing) {
tracer = tracing.tracer();
extractor = tracing.propagation().extractor(GETTER);
injector = tracing.propagation().injector(SETTER);
}
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
logger.info("Dubbo Parameters ==>> " + invoker.getUrl().getParameters());
logger.info("Interface ==>> " + buildSpanName(invoker, invocation));
if (tracer == null) {
logger.info("Tracer is null.");
return invoker.invoke(invocation);
}
//do something...
}`
`public class TracingExtensionFactory implements ExtensionFactory {
@Autowired
Tracing tracing;
@Override
public <T> T getExtension(Class<T> type, String name) {
if (type != Tracing.class) {
return null;
}
if (tracing == null) {
return null;
}
return (T) tracing;
}
}`
`@Configuration
public class TracingConfiguration {
@Value("${spring.application.name}")
private String serverName = "UNKNOWN";
@Value("${dubbo.zipkin.enabled}")
private boolean enabled = false;
@Value("${dubbo.zipkin.endpoint}")
private String endpoint = "http://localhost:9411/api/v2/spans";
@Value("${dubbo.zipkin.rate}")
private float rate = 1.0f;
@Bean
public Sender sender() {
if (!enabled) {
return null;
}
return OkHttpSender.create(endpoint);
}
@Bean
public AsyncReporter<Span> spanReporter() {
if (!enabled) {
return null;
}
return AsyncReporter.create(sender());
}
@Bean
public Tracing tracing() {
if (!enabled) {
return null;
}
return Tracing.newBuilder()
.localServiceName(serverName)
.spanReporter(spanReporter())
.sampler(Sampler.create(rate))
.build();
}
}`
配置如下:
![image](https://user-images.githubusercontent.com/2172570/42790345-2536c3c0-899d-11e8-8b45-10b4dc4909de.png)
![image](https://user-images.githubusercontent.com/2172570/42790359-370413d2-899d-11e8-9ff1-c3025fd4f6e2.png)
![image](https://user-images.githubusercontent.com/2172570/42790382-4fc4634a-899d-11e8-854c-c399b698884a.png)
在本机spring boot方式启动时,可以正常进入filter,并执行后续逻辑
但在使用阿里云EDAS环境时,始终进入不了自己扩展的Filter和ExtensionFactory
请问这与EDAS环境有关吗?如何解决?
for example:
[https://github.com/34176470/springboot-dubbo-zipkin-brave.git](url)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org