Skip to content

feat: configuration for custom temporary file paths - #340

Merged
korniltsev-grafanista merged 1 commit into
grafana:mainfrom
StevenCurran:feature/jfr-location-config
Jul 30, 2026
Merged

korniltsev-grafanista merged 1 commit into
grafana:mainfrom
StevenCurran:feature/jfr-location-config

Conversation

@StevenCurran

Copy link
Copy Markdown
Contributor

Support config driven locations for .jfr files and bootstrap jars to avoid them going into the /tmp dir for apps that want to control this.

@StevenCurran
StevenCurran requested review from a team as code owners July 22, 2026 00:51
@cla-assistant

cla-assistant Bot commented Jul 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Jul 22, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment thread agent/src/test/java/io/pyroscope/javaagent/AsyncProfilerDelegateJfrDirTest.java Outdated
Comment thread agent/src/main/java/io/pyroscope/javaagent/config/Config.java Outdated
Comment thread agent/src/main/java/io/pyroscope/javaagent/util/JfrFileUtil.java Outdated
private static final String PYROSCOPE_HTTP_HEADERS = "PYROSCOPE_HTTP_HEADERS";
private static final String PYROSCOPE_TENANT_ID = "PYROSCOPE_TENANT_ID";
private static final String PYROSCOPE_PROFILE_EXPORT_TIMEOUT = "PYROSCOPE_PROFILE_EXPORT_TIMEOUT";
private static final String PYROSCOPE_JFR_DIR = "PYROSCOPE_JFR_DIR";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be called PYROSCOPE_TMP_DIR ? since it is used for both JFR and jar files

@StevenCurran StevenCurran Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread agent/src/main/java/io/pyroscope/javaagent/config/Config.java Outdated
Comment thread agent/src/main/java/io/pyroscope/javaagent/JFRJCMDProfilerDelegate.java Outdated
@StevenCurran
StevenCurran force-pushed the feature/jfr-location-config branch from 3e9d69d to c7ea30a Compare July 22, 2026 11:25
@StevenCurran
StevenCurran force-pushed the feature/jfr-location-config branch from d9319b7 to 4be8edd Compare July 22, 2026 11:38
Comment thread agent/src/main/java/io/pyroscope/javaagent/AsyncProfilerDelegate.java Outdated
@StevenCurran

Copy link
Copy Markdown
Contributor Author

@korniltsev-grafanista let me know how this looks

@korniltsev-grafanista korniltsev-grafanista changed the title Add configuration for custom temporary file paths feat: configuration for custom temporary file paths Jul 23, 2026
private String basicAuthUser;
private String basicAuthPassword;
private String jfrProfilerSettings;
private String tmpDir;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please annotate tmp dir fields and args as Nullable where appropriate. I know its not done for all the fields, but I think it improves readability

this.format = config.format;

if (format == Format.JFR && null == tempJFRFile) {
if (config.tmpDir != null && config.tmpDir.contains(",")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move this validation to config builder routines

@korniltsev-grafanista korniltsev-grafanista left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm with few nits
thanks

@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown

Signed commits report

All 1 commit between main and feature/jfr-location-config have verified signatures. ✅

Comment thread agent/src/main/java/io/pyroscope/javaagent/config/Config.java
@StevenCurran
StevenCurran force-pushed the feature/jfr-location-config branch from cc7ecd6 to 4b71396 Compare July 25, 2026 00:08
Comment thread agent/src/main/java/io/pyroscope/javaagent/config/Config.java
@StevenCurran

Copy link
Copy Markdown
Contributor Author

lgtm with few nits thanks

Sorry for delay, addressed and push. lmk if all good.

@korniltsev-grafanista korniltsev-grafanista left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please take a look at #340 (comment) report, it looks valid to me.

otherwise lgtm

@StevenCurran
StevenCurran force-pushed the feature/jfr-location-config branch from 4b71396 to 94bf6d6 Compare July 27, 2026 15:52
@StevenCurran

Copy link
Copy Markdown
Contributor Author

please take a look at (earlier comment) report, it looks valid to me.

otherwise lgtm

Updated addressing this, with a test too.

try {
resolved = Paths.get(tmpDir).toAbsolutePath().toString();
} catch (java.nio.file.InvalidPathException e) {
resolved = tmpDir; // invalid path is caught later in TmpFileUtil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I dont understand, why do we swallow it here and resurface somewhere else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, fixed when Path

public final String APExtraArguments;
public final String basicAuthUser;
public final String basicAuthPassword;
public final @Nullable String tmpDir;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we make it Path ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

return createTempFile(config.tmpDir, "pyroscope", ".jfr");
}

public static File createTempFile(String dir, String prefix, String suffix) throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@StevenCurran
StevenCurran force-pushed the feature/jfr-location-config branch from 94bf6d6 to 3591c20 Compare July 28, 2026 23:29

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3591c20. Configure here.

@StevenCurran
StevenCurran force-pushed the feature/jfr-location-config branch from 3591c20 to cad5b10 Compare July 28, 2026 23:44

@korniltsev-grafanista korniltsev-grafanista left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Last request. All contributions are required to sign their commits with gpg/ssh
https://community.grafana.com/t/action-required-signed-commits-mandatory-for-all-grafana-repositories/163404

I can't merge without this

@StevenCurran
StevenCurran force-pushed the feature/jfr-location-config branch 2 times, most recently from 1a87637 to d501ac8 Compare July 29, 2026 22:36
…ncludes bootstream jar, and the .jfr files created by the agent delegates. Signed commit
@StevenCurran
StevenCurran force-pushed the feature/jfr-location-config branch from d501ac8 to f6dbc2c Compare July 29, 2026 22:37
@StevenCurran

Copy link
Copy Markdown
Contributor Author

LGTM

Last request. All contributions are required to sign their commits with gpg/ssh community.grafana.com/t/action-required-signed-commits-mandatory-for-all-grafana-repositories/163404

I can't merge without this

I squashed the commits and sorted out the GPG key, commit is showing verified now!

@korniltsev-grafanista
korniltsev-grafanista merged commit a008256 into grafana:main Jul 30, 2026
72 checks passed
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