How the trace methods works in java agent?

Hi,
I would like to know how the trace methods work in java agent which creates spans for each method invoked during a transaction.

  1. How does the agent keep track of which functions belongs to which transaction, as there can be multiple transactions active at a time.
  2. What if there are multiple threads within a transaction, how does the agent map a particular thread to transaction?

These above questions are based on my assumption of how it works. Any documentation I can read on its implementation will be appreciated.

Thanks, and regards.
Abhijith

Hi,

We have a general explaination in our FAQ.

Yes, there can be multiple transactions at a time, and the ability to track which transaction/span is currently active (and also parent/child relationships) is called context-propagation and it's a broad topic.

In general, if the span/transaction remains active on a given thread, then we use a thread-based context propagation with a stack of activated spans/transactions.

When the span/transaction is delegated to another thread, then we keep the link by wrapping the delegated task or using an intermediate object in a key/value map to be able to retrieve the context.

Hi @Sylvain_Juge
Thank you for the reply

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.