@@ -64,17 +64,15 @@ public void afterAgent(AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetr
6464 }
6565
6666 configurationLogger .log (config );
67- logger .info ("JFR profiler is active." );
67+ logger .info ("Profiler is active." );
6868 executor .submit (
6969 logUncaught (
7070 () -> activateJfrAndRunForever (config , autoConfiguredOpenTelemetrySdk .getResource ())));
7171 }
7272
7373 private boolean notClearForTakeoff (ConfigProperties config ) {
7474 if (!config .getBoolean (CONFIG_KEY_ENABLE_PROFILER , false )) {
75- logger .fine ("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" );
76- logger .fine ("xxxxxxxxx JFR PROFILER DISABLED! xxxxxxxxx" );
77- logger .fine ("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" );
75+ logger .fine ("Profiler is not enabled." );
7876 return true ;
7977 }
8078 if (!JFR .instance .isAvailable ()) {
@@ -83,35 +81,42 @@ private boolean notClearForTakeoff(ConfigProperties config) {
8381 return true ;
8482 }
8583
86- Path outputDir = Paths .get (config .getString (CONFIG_KEY_PROFILER_DIRECTORY ));
84+ return false ;
85+ }
86+
87+ private boolean checkOutputDir (Path outputDir ) {
8788 if (!Files .exists (outputDir )) {
8889 // Try creating the directory for the user...
8990 try {
9091 Files .createDirectories (outputDir );
9192 } catch (IOException e ) {
92- return outdirWarn (outputDir , "does not exist and could not be created" );
93+ outdirWarn (outputDir , "does not exist and could not be created" );
94+ return false ;
9395 }
9496 }
9597 if (!Files .isDirectory (outputDir )) {
96- return outdirWarn (outputDir , "exists but is not a directory" );
98+ outdirWarn (outputDir , "exists but is not a directory" );
99+ return false ;
97100 }
98101
99102 if (!Files .isWritable (outputDir )) {
100- return outdirWarn (outputDir , "exists but is not writable." );
103+ outdirWarn (outputDir , "exists but is not writable." );
104+ return false ;
101105 }
102- return false ;
103- }
104106
105- private boolean outdirWarn (Path dir , String suffix ) {
106- logger .log (
107- WARNING ,
108- "PROFILER WILL NOT BE STARTED: The configured output directory {0} {1}." ,
109- new Object [] {dir , suffix });
110107 return true ;
111108 }
112109
110+ private void outdirWarn (Path dir , String suffix ) {
111+ logger .log (WARNING , "The configured output directory {0} {1}." , new Object [] {dir , suffix });
112+ }
113+
113114 private void activateJfrAndRunForever (ConfigProperties config , Resource resource ) {
115+ boolean keepFiles = keepFiles (config );
114116 Path outputDir = Paths .get (config .getString (CONFIG_KEY_PROFILER_DIRECTORY ));
117+ if (keepFiles && !checkOutputDir (outputDir )) {
118+ keepFiles = false ;
119+ }
115120 RecordingFileNamingConvention namingConvention = new RecordingFileNamingConvention (outputDir );
116121
117122 int stackDepth = Configuration .getStackDepth (config );
@@ -167,7 +172,7 @@ private void activateJfrAndRunForever(ConfigProperties config, Resource resource
167172 .jfr (JFR .instance )
168173 .onNewRecording (jfrRecordingHandler )
169174 .namingConvention (namingConvention )
170- .keepRecordingFiles (keepFiles ( config ) )
175+ .keepRecordingFiles (keepFiles )
171176 .build ();
172177
173178 RecordingSequencer sequencer =
0 commit comments