I custom a span and I see can use 'span.injectTraceHeaders((name, value) -> request.addHeader(name, value));' to implement RPC framework,but I don't know the name I can set? Another,the operate '->' must need java 8?beause when I direct use it,it compile failre,This is my code:
span.injectTraceHeaders((name, value) -> RpcContext.getContext().setAttachment(name, value));
Yes that is a Java Lambda Expression which require Java 8+
You can take a look at this sample repo that has a very simple example of how to use the HeaderInjector and HeaderExtractor framework.
You need to implement the
HeaderInjector
and the HeaderExtractor
It is up to you how you do that, in the message itself, in the header etc. This is just an example you probably want to do it more thoughtfully for production. This is an example with just raw TCP.
Note the Trace Timeline / Waterfall will probably not look correct in Elasticsearch 6.5.1 as there were fixes in Elasticsearch 7.2 for that visualization.
To add on top of the last comment: you don't need to know the name of the header. The agent only expects you provide it with the ability to add the context- an implementation for the HeaderInjector interface that gets a name and a value and knows what to do with them in your specific framework. The agent will invoke this method with the right header name and header value. Same for the HeaderExtractor.
Please take the time to read through @stephenb's examples.
For pre-8 Java, you can use an explicit implementation of the header in a "regular" class implementing it, or anonymous, as such:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.