How to capture distributed tracing ID in our java programatically with OneAgentSDK. Is there any way?
Hello @PraveenYendluri ,
sure you can. Check documentation oneAgentSDK for JAVA.
OneAgentSDK oneAgentSdk = OneAgentSDKFactory.createInstance();
OutgoingRemoteCallTracer outgoingRemoteCall = oneAgentSdk.traceOutgoingRemoteCall(“remoteMethodToCall”, “RemoteServiceName”, “rmi://Endpoint/service”, ChannelType.TCP_IP, “remoteHost:1234”);
outgoingRemoteCall.setProtocolName(“RMI/custom”);
outgoingRemoteCall.start();
try {
String tag = outgoingRemoteCall.getDynatraceStringTag();
// make the call and transport the tag across to server
} catch (Throwable e) {
outgoingRemoteCall.error(e);
// rethrow or add your exception handling
} finally {
outgoingRemoteCall.end();
}
Best Regards
Thank you Michal!!
I am not sure, I got your you message. My requirement is as I pasted below can I get two values highlighted in yellow. I have seen these values in Distributed Traces. I am trying with
TraceContextInfo t = oneAgentSdk.getTraceContextInfo();
log.info("ACTIVE Dynatrace Trace ID: " + t.getTraceId() + " & SpanId:: " + t.getSpanId());
But I am getting 000000000000 values for both trace id and span id.
Bottom Line is I need to get W3C trace ID. Ex: 522dede9e76d809281cd7cdb969934a7
Coming to your code, method oneAgentSdk.traceOutgoingRemoteCall is taking 5 parameters
String serviceMethod, String serviceName, String serviceEndpoint, ChannelType channelType, String channelEndpointHow do I get these values ? Please advise me.Thank you Praveen
Dear @PraveenYendluri,
I hard to say why you have 00000000 instead of actual values. Probably you make systematical error somewhere. Make sure that you are using OneAgentSDK in right place(function which is actually monitored by DT) and OneAgent is up and running.
oneAgentSdk.traceOutgoingRemoteCall is a method to extend normal visibility of Dynatrace. If your method is not monitored by Dynatrace you can use it and have extra node in PurePath.
Parameters of this function is basically how wish to see trace in Dynatrace. That mean you can choose whatever value you wish(there are limitation, but in principle):
Best Regards
Michał

