opentracing / opentracing-java

OpenTracing API for Java. 🛑 This library is DEPRECATED! https://github.com/opentracing/specification/issues/163
http://opentracing.io
Apache License 2.0
1.68k stars 344 forks source link

How to access Span and Baggage item in Java? #293

Closed gvkarthik93 closed 6 years ago

gvkarthik93 commented 6 years ago

I have a client-server architecture. Microservice A is building a span using the following code and sending request to Microservice B.

@RequestMapping("/chaining") public String chaining() { Span span = tracer.buildSpan("build-span-test").start(); span.setBaggageItem("baggage-key", "baggage-value"); span.close(); ResponseEntity<String> response = restTemplate.getForEntity("http://localhost:8092/receive", String.class); return "Chaining + " + response.getBody(); }

Now how can I access this span and baggage on Microservice B?

Following is the code I have for Microservice B:

@RequestMapping("/receive") String testhome(@RequestHeader HttpHeaders headers) { return "Response from Server"; }

I tried buldspan but it's building new span. Can you please tell me what I need to put in this code to access the span and baggage built on Microservice A in the Microservice B?

yurishkuro commented 6 years ago

Please see https://github.com/yurishkuro/opentracing-tutorial/, it covers this.