HI Team,
I had added a custom change in elastic apm agent's source code where in : \apm-agent-core\src\main\java\co\elastic\apm\agent\impl\transaction\transaction.java -> beforeEnd()
to get all the active threads in jvm to get the stacktrace for java apm-agent in windows Operating System.
This code change is giving me stacktrace of all the java files , methods, line numbers.
Can you please provide your thoughts on this, if it is effective way to get the stacktrace of java files in windows OS.
Also, can you please guide me on following issue :
the stacktrace is getting recorded but the json of transaction is as follows (copied the relative json only.):
Could you help me understand what you are trying to achieve here exactly ?
Do you want to capture the stack trace of all running threads ?
This part of the agent is not OS specific, thus there is nothing particular with Windows here.
There is a limit on the JSON payload size when sending this to the APM server, so by setting a custom field to contain stack traces of multiple threads you are hitting the limit.
What you seem to refer as "slow tracing", is actually "sampling profiler", which is an alternate way to capture slow parts of the code to complement tracing which is provided through automatic instrumentation.
As explained briefly here, the sampling profiler should only be relevant to create spans by sampling the threads and correlate them to an active transaction. Unfortunately because it relies on async-profiler this feature is not available on Windows.
What you seem to be trying to do here is to capture the thread state of all the active threads within a single transaction, probably with only a single sample, which means that you'll get both too much data to serialize (the spans created by the sampling profiler are "flattened"), and you will have only a single sample whereas the sampling profiler captures them with a rather high frequency (I don't recall the exact default value here).
If you really want to implement such a feature on Windows by iterating over all the other threads, you'll have to do the following:
create an agent plugin, probably more convenient if it's an external one
sample the thread states at a regular interval
correlate the stack traces to the active transactions and spans
re-construct inferred spans from the samples like the sampling profiler does
So, while it's definitely doable, this could be quite an extensive task, but it could also be worth it if you really need this and your production environment is on Windows.
If on the other end it's only for local development or testing, then I would suggest trying to run your application under linux if you can, using Docker or Windows Subsystem for Linux (WSL) would be the most convenient options.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.