-
Notifications
You must be signed in to change notification settings - Fork 937
Description
Describe the feature
We would like to expose a Dictionary javaThreadIds that maps eventIds to javaThreadIds in JfrReader.
Use Case
In order to implement profiling for the sentry-java sdk we had to vendor-in the JfrReader.java in order to get the JavaThread Ids, which we need to map them to running transactions.
If this feature would be implemented we could depend on the jfr-converter as-is without vendoring and customizing.
We can also supply a PR for this, if you'd like.
Proposed Solution
As part of the readThread method in JfrReader (
async-profiler/src/converter/one/jfr/JfrReader.java
Lines 453 to 464 in ea09546
| private void readThreads(int fieldCount) { | |
| int count = threads.preallocate(getVarint()); | |
| for (int i = 0; i < count; i++) { | |
| long id = getVarlong(); | |
| String osName = getString(); | |
| int osThreadId = getVarint(); | |
| String javaName = getString(); | |
| long javaThreadId = getVarlong(); | |
| readFields(fieldCount - 4); | |
| threads.put(id, javaName != null ? javaName : osName); | |
| } | |
| } |
We would propose to track the javaThreads in a Dictionary just like the threads are tracked by their name, so we can map them from the event id.
Here's our version of the JfrReader for reference: https://github.com/getsentry/sentry-java/blob/main/sentry-async-profiler/src/main/java/io/sentry/asyncprofiler/vendor/asyncprofiler/jfr/JfrReader.java
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change