APM manual distributed tracing

Welcome to the forum and thanks for the question :slight_smile:

You are using the distributed-tracing APIs wrong. You found the right documentation, but misinterpreted the code - it uses lambdas that only implement the way of setting and getting the header, without knowing the header name and value. Those are the responsibility of the agent.

Try changing

span.injectTraceHeaders((name, value) -> 
                    conn.setRequestProperty("Myspan", "100"));

to

span.injectTraceHeaders((name, value) -> 
                    conn.addRequestProperty(name, value));

and

Transaction transaction =ElasticApm.startTransactionWithRemoteParent(key>
                    request.getHeader("Myspan"));

to

Transaction transaction = ElasticApm.startTransactionWithRemoteParent(key ->
                    request.getHeader(key));
2 Likes