OneAgent-SDK-for-Java icon indicating copy to clipboard operation
OneAgent-SDK-for-Java copied to clipboard

Using SDK in a JAVA app that is already auto instrumented

Open arav1895agy opened this issue 3 months ago • 0 comments
trafficstars

  1. We have JAVA app that is auto instrumented with OneAgent. We have some background JOBS (Currently showing under Requests executed in background thread) for which we need to give trace name and attributes so that it come under pure paths and it is named suitable for tracking various background activities.

My background job can either be a scheduled CRON or a process triggered out of message consumption from queue.

My background job has a flow like below: Background job -> Inter service call to other java microservice / RMQ message / DB calls -> job ends

Question: With the above flow in mind, If I start a trace with OTEL, will those inter service calls / RMQ / DB be auto-instrumented with OneAgent or OTEL has to take care of it since it started the trace?

In case the RMQ publish was triggered by a auto instrumented HTTP request and I name a span before / after publish with OTEL, is the entire auto instrumentation for the HTTP request lost?

  1. Custom attributes are supported at SDK object level OneAgentSDK oneAgentSdk = OneAgentSDKFactory.createInstance(); IncomingMessageProcessTracer incomingMessageProcessTracer = oneAgentSdk.traceIncomingMessageProcess(MessagingSystemInfoNoop.INSTANCE); incomingMessageProcessTracer.start(); oneAgentSdk.addCustomRequestAttribute("requestId", amqpMessage.getRequestId());

Question: In a multi threaded world, do we need to create OneAgentSDK object once per request so that addCustomRequestAttribute is thread safe or dyna trace handles addCustomRequestAttribute for multiple threads automatically with a single instance?

  1. Even for the auto instrumented cases, I have few areas where i specifically need to add extra attributes / track a DB statement in a detailed way, etc . to have more developer oriented info. Need to have the best of both worlds of OTEL / OneAgent here. What is the best suggested approach.

arav1895agy avatar Aug 22 '25 14:08 arav1895agy