Skip to content

Commit c7ea30a

Browse files
stevencurranclaude
andcommitted
fix: restore PYROSCOPE_TMP_DIR as the Java constant name in Config
Previous commit shortened it to TMP_DIR; restore the full name so the constant identifier matches its string value, consistent with the rest of the Config constants. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> refactor: rename config key from PYROSCOPE_JFR_DIR to PYROSCOPE_TMP_DIR The setting controls the directory for all agent temp files (bootstrap jar, JFR recordings), not just JFR. Rename the env var / system property to PYROSCOPE_TMP_DIR (pyroscope.tmp.dir in dotted-lowercase form) to reflect that. - Config: TMP_DIR constant replaces PYROSCOPE_TMP_DIR, string value updated - BootstrapApiInjector: constant and lookup key updated - AsyncProfilerDelegate: error message updated - Tests: all "PYROSCOPE_JFR_DIR" and "pyroscope.jfr.dir" string literals updated Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 317b21c commit c7ea30a

5 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎agent/src/main/java/io/pyroscope/javaagent/AsyncProfilerDelegate.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void setConfig(@NotNull final Config config) {
4747
if (format == Format.JFR && null == tempJFRFile) {
4848
if (config.jfrDir != null && config.jfrDir.contains(",")) {
4949
throw new IllegalStateException(
50-
"PYROSCOPE_JFR_DIR must not contain commas — async-profiler uses comma as option separator: " + config.jfrDir);
50+
"PYROSCOPE_TMP_DIR must not contain commas — async-profiler uses comma as option separator: " + config.jfrDir);
5151
}
5252
try {
5353
tempJFRFile = JfrFileUtil.createJfrFile(config);

‎agent/src/main/java/io/pyroscope/javaagent/BootstrapApiInjector.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
class BootstrapApiInjector {
3737

3838
private static final String RESOURCE_NAME = "/pyroscope-bootstrap.jar.bin";
39-
private static final String PYROSCOPE_JFR_DIR = "PYROSCOPE_JFR_DIR";
39+
private static final String PYROSCOPE_TMP_DIR = "PYROSCOPE_TMP_DIR";
4040

4141
static void inject(Instrumentation instrumentation) {
4242
String jfrDir = getJfrDir();
4343
inject(instrumentation, jfrDir);
4444
}
4545

4646
private static String getJfrDir() {
47-
return DefaultConfigurationProvider.INSTANCE.get(PYROSCOPE_JFR_DIR);
47+
return DefaultConfigurationProvider.INSTANCE.get(PYROSCOPE_TMP_DIR);
4848
}
4949

5050
static void inject(Instrumentation instrumentation, String jfrDir) {

‎agent/src/main/java/io/pyroscope/javaagent/config/Config.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public final class Config {
5858
private static final String PYROSCOPE_HTTP_HEADERS = "PYROSCOPE_HTTP_HEADERS";
5959
private static final String PYROSCOPE_TENANT_ID = "PYROSCOPE_TENANT_ID";
6060
private static final String PYROSCOPE_PROFILE_EXPORT_TIMEOUT = "PYROSCOPE_PROFILE_EXPORT_TIMEOUT";
61-
private static final String PYROSCOPE_JFR_DIR = "PYROSCOPE_JFR_DIR";
61+
private static final String PYROSCOPE_TMP_DIR = "PYROSCOPE_TMP_DIR";
6262

6363
/**
6464
* Experimental feature, may be removed in the future
@@ -666,7 +666,7 @@ private static String tenantID(ConfigurationProvider cp) {
666666
}
667667

668668
private static String jfrDir(ConfigurationProvider cp) {
669-
return cp.get(PYROSCOPE_JFR_DIR);
669+
return cp.get(PYROSCOPE_TMP_DIR);
670670
}
671671

672672
private static Duration samplingDuration(ConfigurationProvider configurationProvider) {

‎agent/src/test/java/io/pyroscope/javaagent/BootstrapApiInjectorJfrDirTest.java‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public class BootstrapApiInjectorJfrDirTest {
2525

2626
@BeforeEach
2727
void setUp() {
28-
System.clearProperty("PYROSCOPE_JFR_DIR");
29-
System.clearProperty("pyroscope.jfr.dir");
28+
System.clearProperty("PYROSCOPE_TMP_DIR");
29+
System.clearProperty("pyroscope.tmp.dir");
3030
}
3131

3232
@AfterEach
3333
void tearDown() {
34-
System.clearProperty("PYROSCOPE_JFR_DIR");
35-
System.clearProperty("pyroscope.jfr.dir");
34+
System.clearProperty("PYROSCOPE_TMP_DIR");
35+
System.clearProperty("pyroscope.tmp.dir");
3636
}
3737

3838
@Test
@@ -111,20 +111,20 @@ private void testCreateBootstrapJarMethod(String jfrDir) throws Exception {
111111
@Test
112112
void testGetJfrDirFromSystemProperty() throws Exception {
113113
String jfrDir = tempDir.toString();
114-
System.setProperty("PYROSCOPE_JFR_DIR", jfrDir);
114+
System.setProperty("PYROSCOPE_TMP_DIR", jfrDir);
115115

116116
java.lang.reflect.Method method = BootstrapApiInjector.class.getDeclaredMethod("getJfrDir");
117117
method.setAccessible(true);
118118
String result = (String) method.invoke(null);
119119

120120
assertEquals(jfrDir, result,
121-
"Should read PYROSCOPE_JFR_DIR from system property (-D flag)");
121+
"Should read PYROSCOPE_TMP_DIR from system property (-D flag)");
122122
}
123123

124124
@Test
125125
void testGetJfrDirPrefersSystemPropertyOverEnv() throws Exception {
126126
String jfrDir = tempDir.toString();
127-
System.setProperty("PYROSCOPE_JFR_DIR", jfrDir);
127+
System.setProperty("PYROSCOPE_TMP_DIR", jfrDir);
128128

129129
java.lang.reflect.Method method = BootstrapApiInjector.class.getDeclaredMethod("getJfrDir");
130130
method.setAccessible(true);
@@ -136,37 +136,37 @@ void testGetJfrDirPrefersSystemPropertyOverEnv() throws Exception {
136136

137137
@Test
138138
void testGetJfrDirFromDottedLowercaseSystemProperty() throws Exception {
139-
// e.g. java -Dpyroscope.jfr.dir=/path -javaagent:pyroscope.jar ...
139+
// e.g. java -Dpyroscope.tmp.dir=/path -javaagent:pyroscope.jar ...
140140
// must match the convention used by -Dpyroscope.application.name etc.
141141
String jfrDir = tempDir.toString();
142-
System.setProperty("pyroscope.jfr.dir", jfrDir);
142+
System.setProperty("pyroscope.tmp.dir", jfrDir);
143143

144144
java.lang.reflect.Method method = BootstrapApiInjector.class.getDeclaredMethod("getJfrDir");
145145
method.setAccessible(true);
146146
String result = (String) method.invoke(null);
147147

148148
assertEquals(jfrDir, result,
149-
"Should read -Dpyroscope.jfr.dir just like other -Dpyroscope.* properties");
149+
"Should read -Dpyroscope.tmp.dir just like other -Dpyroscope.* properties");
150150
}
151151

152152
@Test
153153
void testGetJfrDirPrefersUppercaseSystemPropertyOverDottedLowercase() throws Exception {
154154
String uppercaseDir = tempDir.resolve("uppercase").toString();
155155
String dottedDir = tempDir.resolve("dotted").toString();
156-
System.setProperty("PYROSCOPE_JFR_DIR", uppercaseDir);
157-
System.setProperty("pyroscope.jfr.dir", dottedDir);
156+
System.setProperty("PYROSCOPE_TMP_DIR", uppercaseDir);
157+
System.setProperty("pyroscope.tmp.dir", dottedDir);
158158

159159
java.lang.reflect.Method method = BootstrapApiInjector.class.getDeclaredMethod("getJfrDir");
160160
method.setAccessible(true);
161161
String result = (String) method.invoke(null);
162162

163163
assertEquals(uppercaseDir, result,
164-
"Exact-case PYROSCOPE_JFR_DIR system property should win over the dotted-lowercase form");
164+
"Exact-case PYROSCOPE_TMP_DIR system property should win over the dotted-lowercase form");
165165
}
166166

167167
@Test
168168
void testGetJfrDirFallsBackToNull() throws Exception {
169-
System.clearProperty("PYROSCOPE_JFR_DIR");
169+
System.clearProperty("PYROSCOPE_TMP_DIR");
170170

171171
java.lang.reflect.Method method = BootstrapApiInjector.class.getDeclaredMethod("getJfrDir");
172172
method.setAccessible(true);

‎agent/src/test/java/io/pyroscope/javaagent/config/ConfigJfrDirTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void testConfigBuildFromConfigurationProviderWithJfrDir() {
7171
when(cp.get("PYROSCOPE_PROFILE_EXPORT_TIMEOUT")).thenReturn(null);
7272

7373
String testDir = "/var/lib/pyroscope/jfr";
74-
when(cp.get("PYROSCOPE_JFR_DIR")).thenReturn(testDir);
74+
when(cp.get("PYROSCOPE_TMP_DIR")).thenReturn(testDir);
7575

7676
Config config = Config.build(cp);
7777

@@ -110,7 +110,7 @@ void testConfigBuildFromConfigurationProviderWithoutJfrDir() {
110110
when(cp.get("PYROSCOPE_BASIC_AUTH_USER")).thenReturn(null);
111111
when(cp.get("PYROSCOPE_BASIC_AUTH_PASSWORD")).thenReturn(null);
112112
when(cp.get("PYROSCOPE_PROFILE_EXPORT_TIMEOUT")).thenReturn(null);
113-
when(cp.get("PYROSCOPE_JFR_DIR")).thenReturn(null);
113+
when(cp.get("PYROSCOPE_TMP_DIR")).thenReturn(null);
114114

115115
Config config = Config.build(cp);
116116

0 commit comments

Comments
 (0)