kristofa/brave — pull request #14 by leigu (2014-01-30 15:37:56+00:00)
Title: Add nested client call support

Hi Kistrof,
First of all, I want to thank you for making Zipkin available for Java!
![zipkin-multilevel-tracing](https://f.cloud.github.com/assets/4482075/2041325/0ded5f9a-89c4-11e3-9113-0d92f365acc7.png)

I added nested client tracing support by utilizing a stack for client spans and push and pop them when appropriate setClientSend() and setClientReceived() all comes in, instead of the current only two nested level of tracing.

Here is a sample picture of mulit-level client side tracing.

I also create a Brave client that allows me to trace any method call and here is the code snippet,
@Configuration
public class BraveClientTest {

@Autowired
ZipkinClient zipkinClient;

public BraveClientTest()
{
}
public void trace() throws Exception
{
zipkinClient.startServerTracer("main.foo.twice()");
foo();
cache();
cache();
zipkinClient.stopServerTracer();
}
public static void main(String[] args) throws Exception {
ApplicationContext context =
new ClassPathXmlApplicationContext(new String[] {"brave-context.xml"});

BraveClientTest braveTest = context.getBean(BraveClientTest.class);
braveTest.trace();

}
private void foo() throws Exception
{
Thread.sleep(500);
}
private void cache() throws Exception
{
zipkinClient.startClientTracer("main.cache.cache()");
zipkinClient.submitAnnotation("annotation - cache-context-value", "annotation id is 123");
zipkinClient.submitBinaryAnnotation("binary annotation - cache-context-value", "session id is 123");
Thread.sleep(250);
cache1();
zipkinClient.stopClientTracer();
}
private void cache1() throws Exception
{
zipkinClient.startClientTracer("main.cache.cache1()");
Thread.sleep(250);
zipkinClient.stopClientTracer();
}

}

One just need to wrap the actual method call with startClientTracer and stopClientTracer. Let me know if you have any interest in integrating this class into Brave.
Thanks again for your wonderful work.
-- Lei