Skip to content

Conversation

@jake-kramer
Copy link
Contributor

This tool is used to modify a .pyroscope.yaml file with source code mappings for 3rd party libraries from a given jar.

It uses heuristics and 3rd party APIs to try to resolve discovered 3rd party library functions in to git repos.

There is also a hard coded mapping in jar-mappings.json for any popular 3rd party libraries that the tool's heuristics are unable to resolve.

This tool is used to modify a `.pyroscope.yaml` file with source
code mappings for 3rd party libraries from a given jar.

It uses heuristics and 3rd party APIs to try to resolve discovered
3rd party library functions in to git repos.

There is also a hard coded mapping in `jar-mappings.json` for any
popular 3rd party libraries that the tool's heuristics are unable
to resolve.
@jake-kramer jake-kramer requested review from a team, bryanhuhta and marcsanmi as code owners November 25, 2025 21:00
@jake-kramer jake-kramer marked this pull request as draft November 28, 2025 16:14
"strings"
)

type CommandRunner interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of this interface?

"time"
)

type HTTPClient interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of this interface? Can't we use http.Client?

}

// MavenService handles downloading JAR files from Maven Central.
type MavenService struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MavenService is not used?


// extractJDKVersionFromJAR extracts the JDK version from a JAR file by analyzing
// the class file major version numbers. Returns the major version (e.g., "8", "11", "17").
func extractJDKVersionFromJAR(jarPath string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class version in the class file header is not the version of the JDK used to run the program. I am not 100% sure but it's likely the javac -target <TARGET> used at compile time. Furthermore libraries are often compiled with low target to allow running on many JDKs, a lot of them target 8 or 11 JDKs. Running this logic against different libraries would produce different results. It should only run against non libraries classes, but even then it's not reliable as app devs can still compile to a different target (they have less reasons than the lib devs, but still)

@@ -0,0 +1,124 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the main config yaml, and this config is json?

{
"mappings": [
{
"jar": "tomcat-embed-core",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this field is compared against artifact id, then maybe rename the field to artifact_id

"path": "spring-boot-project/spring-boot-autoconfigure/src/main/java"
},
{
"jar": "agent",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean any artifact with the name agent will resolve to pyroscope-java ? this does not seem right


func main() {
var (
jarPath = flag.String("jar", "", "Path to the Java JAR file to analyze")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I expected to call this tool on every dependency manually? This is not very convenient. We should at least allow passing multiple jars or a directory(ies?) of jars.

}

// Check for Bazel runfiles directory (e.g., ProjectRunner.runfiles for ProjectRunner.jar)
bazelJARs := e.findBazelRunfileJARs(jarPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the customer we build this for have these files and does it work for them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants