...
Code Block |
---|
|
final Map<String, String> properties = new HashMap<String, String>();
final HTraceConfiguration conf = HTraceConfiguration.fromMap(properties);
Trace.addReceiver(new StandardOutSpanReceiver(conf));
final HTraceClientProvider provider = new HTraceClientProvider(new AlwaysSampler(conf));
final Client client = ClientBuilder.newClient().register(provider);
final Response response = client
.target("http://localhost:8282/rest/api/people")
.request()
.accept(MediaType.APPLICATION_JSON)
.get(); |
To change the default HTTP header names, used to transfer the tracing context from client to server, it is enough to define two properties only: TracerHeaders.HEADER_SPAN_ID and TracerHeaders.HEADER_TRACE_ID. For example:
Code Block |
---|
|
final ClientConfiguration config = WebClient.getConfig(client);
config.getRequestContext().put(TracerHeaders.HEADER_SPAN_ID, "CUSTOM_HEADER_SPAN_ID");
config.getRequestContext().put(TracerHeaders.HEADER_TRACE_ID, "CUSTOM_HEADER_TRACE_ID"); |
Warning |
---|
It is very important to keep client and server HTTP headers configuration in sync, otherwise the server won't be able to establish the current tracing context properly. |
Configuring Server
Anchor |
---|
| configure.server |
---|
| configure.server |
---|
|
...