openzipkin / zipkin

Zipkin is a distributed tracing system
https://zipkin.io/
Apache License 2.0
17.02k stars 3.09k forks source link

Tracing services that use different languages (Js and Java) and frameworks #1235

Closed jpiechowka closed 8 years ago

jpiechowka commented 8 years ago

I would like to use Zipkin tracing in our application. I have created proof of concept application on frameworks that we use in our commercial app. Front end web application is created in Polymer, and server is created in Java Spark web framework. I have got simple button that will send a request to the Spark server, server will receive the request, sleep for random time and return response. I would like this to be traced. What should I use and what should I do to accomplish this? Is it possible to use different libraries on front and back end?

codefromthecrypt commented 8 years ago

Hi, Janusz.

not sure if either of the frameworks you mentioned have been instrumented, yet, but they'd be done in https://github.com/openzipkin/zipkin-js for the frontend and https://github.com/openzipkin/brave for the backend.

There's a brave example here if it helps.. https://github.com/openzipkin/brave-resteasy-example

feel free to join gitter, too https://gitter.im/openzipkin/zipkin

jpiechowka commented 8 years ago

Thank you Adrian for your reply. Unfortunately I cannot access gitter from work.

So on the server side, at the beginning I build new Brave object like this:

Brave brave = new Brave.Builder("Server")
                .spanCollector(HttpSpanCollector.create("http://localhost:9411/",new EmptySpanCollectorMetricsHandler()))
                .build();

Then I played around and I was able to send spans to zipkin like this:

SpanId span = brave.localTracer().startNewSpan("TEST SPAN", request.url());

brave.localTracer().startNewSpan("SPAN", request.url());
brave.localTracer().submitAnnotation("sr");

Thread.sleep(2000);

brave.localTracer().submitAnnotation("ss");
brave.localTracer().finishSpan();

I don't really understand how to use clientTracer(), serverTracer(), or the interceptors. And the example provided is not very helpful. Can I use localTracer for tracing like this?

How to extract all the necessary ids that I receive in the HTTP request for use with brave?

codefromthecrypt commented 8 years ago

The example wasn't how to instrument Java Spark, it was how to run a java setup in general. Glad you were able to do that.

For example, to instrument the Spark framework, something like below would be needed: https://github.com/openzipkin/brave/blob/fd3cdb921964a0d7164c29141fe6aac8099ae4cf/brave-spring-web-servlet-interceptor/src/main/java/com/github/kristofa/brave/spring/ServletHandlerInterceptor.java maybe using this? https://github.com/perwendel/spark/blob/master/src/main/java/spark/Filter.java Here are details on brave's hooks: https://github.com/openzipkin/brave/tree/master/brave-http

Popular frameworks end up in Brave, the first step in making something popular is opening an issue. I'd open one for the sparkjava https://github.com/openzipkin/brave/issues

If you can't use gitter, then probably best to move this to a zipkin-user email since this is an open-ended conversation (as opposed to something we can fix in this repo). If you do, I'll try to help you there. https://groups.google.com/forum/#!forum/zipkin-user