Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clears up instructions for dubbo config #637

Merged
merged 1 commit into from Mar 7, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -10,19 +10,60 @@ Note: A Dubbo Provider is a server, and a Dubbo Consumer is a client in
Zipkin terminology.

## Configuration
The filter "tracing" requires an extension of type `brave.Tracing` named
"tracing" configured. Once that's configured, you assign the filter to
your providers and consumers like so:

The filter "tracing" requires an extension of type `Tracing` configured.
Most typically, this is provided by Spring, so have this in place before
proceeding. Here's an example in [XML](../../spring-beans/README.md).
Here's an example of with Spring 2.5+ [XML](http://dubbo.io/books/dubbo-user-book-en/references/xml/dubbo-consumer.html)
```xml
<!-- default to trace all services -->
<dubbo:consumer filter="tracing" />
<dubbo:provider filter="tracing" />
```

Then, configure the filter named "tracing" in your producer or consumer.
Here's an example with dubbo.properties:
```properties
dubbo.provider.filter=tracing
dubbo.consumer.filter=tracing
```

Here's an example of using Spring 2.5+ XML
```xml
<!-- a provider -->
<dubbo:service filter="tracing" interface="com.alibaba.dubbo.demo.DemoService" ref="demoService"/>
### Registering the `brave.Tracing` extension with Spring
Most typically, the `brave.Tracing` extension is provided by Spring, so
have this in place before proceeding. The bean must be named "tracing"

Here's an example in [XML](../../spring-beans/README.md).

### Registering the `brave.Tracing` extension with Java
Dubbo supports custom extensions. You can supply your own instance of
tracing by creating and registering an extension factory:

#### create an extension factory that returns `brave.Tracing`

<!-- or a consumer -->
<dubbo:reference filter="tracing" id="demoService" check="false" interface="com.alibaba.dubbo.demo.DemoService"/>
```java
package com.yourcompany.dubbo;
import brave.Tracing;
import com.alibaba.dubbo.common.extension.ExtensionFactory;
import zipkin2.reporter.AsyncReporter;
import zipkin2.Span;
public class TracingExtensionFactory implements ExtensionFactory {
@Override public <T> T getExtension(Class<T> type, String name) {
if (type != Tracing.class) return null;
return (T) Tracing.newBuilder()
.localServiceName("my-service")
.spanReporter(spanReporter())
.build();
}
// NOTE: The reporter should be closed with a shutdown hook
AsyncReporter<Span> spanReporter() {
--snip--
```
#### Register that factory using META-INF
Make sure the following line is in `META-INF/dubbo/com.alibaba.dubbo.common.extension.ExtensionFactory` in your classpath:
```
tracing=com.yourcompany.dubbo.TracingExtensionFactory
```
@@ -11,6 +11,7 @@
import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.extension.Activate;
import com.alibaba.dubbo.common.extension.ExtensionLoader;
import com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory;
import com.alibaba.dubbo.remoting.exchange.ResponseCallback;
import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
@@ -34,7 +35,11 @@
TraceContext.Extractor<Map<String, String>> extractor;
TraceContext.Injector<Map<String, String>> injector;

/** {@link ExtensionLoader} supplies the tracing implementation, for example by Spring. */
/**
* {@link ExtensionLoader} supplies the tracing implementation which must be named "tracing". For
* example, if using the {@link SpringExtensionFactory}, only a bean named "tracing" will be
* injected.
*/
public void setTracing(Tracing tracing) {
tracer = tracing.tracer();
extractor = tracing.propagation().extractor(GETTER);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.