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

distributed tracing for armeria #114

Merged
merged 1 commit into from
Mar 3, 2016
Merged

distributed tracing for armeria #114

merged 1 commit into from
Mar 3, 2016

Conversation

synk
Copy link
Contributor

@synk synk commented Feb 20, 2016

Introduces distributed tracing capability to armeria clients/servers. This enables us to watch timing data among the whole armeria rpc chain.

This feature depends on brave distributed tracing library compatible with zipkin.

Decorate HTTP client

// Create a brave instance with service name, span collector, and sampling rate.
Brave brave = new Brave.Builder("FibClientMain")
        .spanCollector(new ScribeSpanCollector("127.0.0.1", 9410))
        .traceSampler(Sampler.create(0.01f))
        .build();

FibService.Iface fibClient =
        new ClientBuilder("tbinary+http://127.0.0.1:8080/thrift/fib")
                .decorator(HttpTracingClient.decorator(brave))
                .build(FibService.Iface.class);

Decorate HTTP server

// Create a brave instance with service name, span collector, and sampling rate.
Brave brave = new Brave.Builder("FibServerMain")
        .spanCollector(new ScribeSpanCollector("127.0.0.1", 9410))
        .traceSampler(Sampler.create(0.01f))
        .build();

ServerBuilder builder = new ServerBuilder();

builder.port(8080, SessionProtocol.HTTP);

VirtualHost vh = new VirtualHostBuilder()
        .serviceAt("/thrift/fib",
                ThriftService.of(new FibServiceHandler(brave))
                             .decorate(HttpTracingService.decorator(brave))
        )
        .build();

Add custom annotations using brave's API

// Add custom attribute to the span in service handler
brave.serverTracer().submitBinaryAnnotation("foo", "bar");

// Add custom timing tag in server handler
brave.serverTracer().submitAnnotation("somethinghappen");

@trustin
Copy link
Member

trustin commented Feb 20, 2016

w00t!

@trustin trustin self-assigned this Feb 20, 2016
@trustin trustin added this to the 0.10.0.Final milestone Feb 20, 2016
@synk
Copy link
Contributor Author

synk commented Feb 20, 2016

@trustin Please take a look

<dependency>
<groupId>com.github.kristofa</groupId>
<artifactId>brave-http</artifactId>
<version>3.4.0</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a property instead of duplicating version numbers?

@trustin
Copy link
Member

trustin commented Feb 23, 2016

@synk First pass done. Please ping me for another pass.

@synk
Copy link
Contributor Author

synk commented Feb 24, 2016

@trustin Thanks. I'll ping when I finished

@synk
Copy link
Contributor Author

synk commented Feb 24, 2016

@trustin I think I handled your comments. Please take a look again.

/**
* Creates a new tracing {@link Client} decorator using the specified {@link Brave} instance.
*/
public static Function<Client, Client> decorator(Brave brave) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about renaming this method to newDecorator() for consistency with MetricCollectingClient.new...Decorator()?

@trustin
Copy link
Member

trustin commented Feb 25, 2016

Please fix the Javadoc errors:

[ERROR] Exit code: 1 - /home/travis/build/line/armeria/src/main/java/com/linecorp/armeria/client/tracing/HttpTracingClient.java:28: error: self-closing element not allowed
[ERROR] * <p/>
[ERROR] ^
[ERROR] /home/travis/build/line/armeria/src/main/java/com/linecorp/armeria/client/tracing/TracingRemoteInvoker.java:44: error: self-closing element not allowed
[ERROR] * <p/>
[ERROR] ^
[ERROR] /home/travis/build/line/armeria/src/main/java/com/linecorp/armeria/server/tracing/TracingServiceInvocationHandler.java:41: error: self-closing element not allowed
[ERROR] * <p/>
[ERROR] ^

It seems like Javadoc does not like <p/> and </p>. (only <p> is allowed for P tags)

@trustin
Copy link
Member

trustin commented Feb 25, 2016

@synk Looks good to me except for a few nits. Please squash for a merge.

@synk
Copy link
Contributor Author

synk commented Feb 25, 2016

@trustin I've squashed. Please merge if it's OK.

* Returns server side annotations that should be added to span.
*/
protected <T> List<KeyValueAnnotation> annotations(ServiceInvocationContext ctx, Future<? super T> result) {
final List<KeyValueAnnotation> annotations = new ArrayList<>(5);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot setting capacity here.

Introduces distributed tracing capability to armeria clients/servers. This enables us to watch timing data among the whole armeria rpc chain. This feature depends on brave distributed tracing library compatible with zipkin.
trustin added a commit that referenced this pull request Mar 3, 2016
distributed tracing for armeria
@trustin trustin merged commit d8051da into line:master Mar 3, 2016
@trustin
Copy link
Member

trustin commented Mar 3, 2016

BOOM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants