KEMBAR78
Expose a dictionary of javaThreads from JfrReader · Issue #1525 · async-profiler/async-profiler · GitHub
Skip to content

Expose a dictionary of javaThreads from JfrReader #1525

@lbloder

Description

@lbloder

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 (

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions