77import static datadog .crashtracking .Initializer .findAgentJar ;
88import static datadog .crashtracking .Initializer .getOomeNotifierTemplate ;
99import static datadog .crashtracking .Initializer .writeConfig ;
10+ import static datadog .trace .api .telemetry .LogCollector .SEND_TELEMETRY ;
1011import static java .nio .file .FileVisitResult .CONTINUE ;
1112import static java .nio .file .StandardCopyOption .REPLACE_EXISTING ;
1213import static java .nio .file .attribute .PosixFilePermissions .asFileAttribute ;
@@ -37,20 +38,24 @@ private OOMENotifierScriptInitializer() {}
3738 // @VisibleForTests
3839 static void initialize (String onOutOfMemoryVal ) {
3940 if (onOutOfMemoryVal == null || onOutOfMemoryVal .isEmpty ()) {
40- LOG .debug ("'-XX:OnOutOfMemoryError' argument was not provided. OOME tracking is disabled." );
41+ LOG .debug (
42+ SEND_TELEMETRY ,
43+ "'-XX:OnOutOfMemoryError' argument was not provided. OOME tracking is disabled." );
4144 return ;
4245 }
4346 Path scriptPath = getOOMEScripPath (onOutOfMemoryVal );
44- System .out .println ("===> OOME notifier script path: " + scriptPath );
4547 if (scriptPath == null ) {
4648 LOG .debug (
49+ SEND_TELEMETRY ,
4750 "OOME notifier script value ({}) does not follow the expected format: <path>/dd_oome_notifier.(sh|bat) %p. OOME tracking is disabled." ,
4851 onOutOfMemoryVal );
4952 return ;
5053 }
5154 String agentJar = findAgentJar ();
5255 if (agentJar == null ) {
53- LOG .warn ("Unable to locate the agent jar. OOME notification will not work properly." );
56+ LOG .warn (
57+ SEND_TELEMETRY ,
58+ "Unable to locate the agent jar. OOME notification will not work properly." );
5459 return ;
5560 }
5661 if (!copyOOMEscript (scriptPath )) {
@@ -85,6 +90,7 @@ private static boolean copyOOMEscript(Path scriptPath) {
8590 Files .createDirectories (scriptDirectory , asFileAttribute (fromString (RWXRWXRWX )));
8691 } catch (UnsupportedOperationException e ) {
8792 LOG .warn (
93+ SEND_TELEMETRY ,
8894 "Unsupported permissions {} for {}. OOME notification will not work properly." ,
8995 RWXRWXRWX ,
9096 scriptDirectory );
@@ -93,11 +99,14 @@ private static boolean copyOOMEscript(Path scriptPath) {
9399 // can be safely ignored; if the folder exists we will just reuse it
94100 if (!Files .isWritable (scriptDirectory )) {
95101 LOG .warn (
96- "Read only directory {}. OOME notification will not work properly." , scriptDirectory );
102+ SEND_TELEMETRY ,
103+ "Read only directory {}. OOME notification will not work properly." ,
104+ scriptDirectory );
97105 return false ;
98106 }
99107 } catch (IOException e ) {
100108 LOG .warn (
109+ SEND_TELEMETRY ,
101110 "Failed to create writable OOME script folder {}. OOME notification will not work properly." ,
102111 scriptDirectory );
103112 return false ;
@@ -108,7 +117,9 @@ private static boolean copyOOMEscript(Path scriptPath) {
108117 Files .setPosixFilePermissions (scriptPath , fromString (R_XR_XR_X ));
109118 } catch (IOException e ) {
110119 LOG .warn (
111- "Failed to copy OOME script {}. OOME notification will not work properly." , scriptPath );
120+ SEND_TELEMETRY ,
121+ "Failed to copy OOME script {}. OOME notification will not work properly." ,
122+ scriptPath );
112123 return false ;
113124 }
114125 return true ;
0 commit comments