I use HeaderInjector for a rpc call,but it doesn't form a trace.The client code is:
Transaction transaction = ElasticApm.currentTransaction();
Span span = transaction.startSpan("external", "tcp", null).setName(methodName);
span.activate();
try{
span.injectTraceHeaders(new HeaderInjector() {
@Override
public void addHeader(String headerName, String headerValue) {
context.put(headerName, headerValue);
}
});
} catch (Exception e) {
span.captureException(e);
span.end();
}
The server code:
Transaction transaction = ElasticApm.startTransactionWithRemoteParent(new HeaderExtractor() {
@Override
public String getFirstHeader(String headerName) {
return context.get(headerName);
}
});
transaction.activate();
try {
transaction.setName("tcp-server");
transaction.setType(Transaction.TYPE_REQUEST);
} catch (Exception e) {
transaction.captureException(e);
transaction.end();
}