diff --git a/scripts/datadog_wrapper b/scripts/datadog_wrapper index cb4a287f..dcd2448a 100644 --- a/scripts/datadog_wrapper +++ b/scripts/datadog_wrapper @@ -67,10 +67,24 @@ then fi export DD_JMXFETCH_ENABLED="false" export DD_RUNTIME_METRICS_ENABLED="false" + export DD_REMOTE_CONFIG_ENABLED="false" + DD_Agent_Jar=/opt/java/lib/dd-java-agent.jar if [ -f "$DD_Agent_Jar" ] then - export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -javaagent:$DD_Agent_Jar -XX:+TieredCompilation -XX:TieredStopAtLevel=1" + # Removes the -XX:-TieredCompilation flag from the java command passed + # through from the Lambda runtime. Allows the JVM to use the C1 compiler + # and Interpreter, which is much faster on cold start and + # uses less memory. + START_COMMAND=${args[0]} + REMAINDER_ARGS=("${args[@]:1}") + for index in "${!REMAINDER_ARGS[@]}" ; do + [[ ${REMAINDER_ARGS[$index]} == "-XX:-TieredCompilation" ]] && unset -v 'REMAINDER_ARGS[$index]' ; + done + REMAINDER_ARGS="${REMAINDER_ARGS[@]}" + # -XX:TieredStopAtLevel=1 tells the compiler to stop at the C1 compiler + args=($START_COMMAND -javaagent:$DD_Agent_Jar -XX:TieredStopAtLevel=1 ${REMAINDER_ARGS[@]}) + else echo "File $DD_Agent_Jar does not exist!" fi