grafana / pyroscope-java

pyroscope java integration
Apache License 2.0
72 stars 31 forks source link

Adds support for multi-event selection if JFR is enabled #88

Closed 6fears7 closed 1 year ago

6fears7 commented 1 year ago

image

Created new builder option: setProfilingEvents

Most notably in Profiler.java, the createJFRCommand ensures that only when the JFR option is enabled will multiple events be used. Otherwise, it'll default to the single Event default set in the Config.

private String createJFRCommand() {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < eventTypes.length; i++) {
            if (i == 0) {
                sb.append("start,event=").append(eventTypes[0].id);
            } else {
                sb.append(",").append(eventTypes[i].id);
            }

        }

Enables end users to utilize the Config Builder to specify multiple event types to mirror the async-profilers command line options

I dig a lot of digging and didn't see any current way in-code for this to work, so if there is and it's simply hidden please let me know.

korniltsev commented 1 year ago

io.pyroscope.javaagent.config.Config.Builder#setProfilingLock

6fears7 commented 1 year ago

Thank you. I was much too focused on getting the method # 1 to work (./profiler.sh -e cpu,alloc,lock -f profile.jfr ...) that I didn't pay any mind to method # 2 (./profiler.sh -e cpu --alloc 2m --lock 10ms -f profile.jfr ...) and how that might've already been used in the Builder