diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fa23dc..ae966c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [2.19] - 2024-04-01 + +### Added +- Datadog Agent pinned versions are now `7.52.0` and `6.52.0`. +- When process monitoring is enabled, the process Agent is embedded in the core Agent (reduces slug size) + ## [2.18] - 2024-02-20 ### Added - Datadog Agent pinned versions are now `7.51.0` and `6.51.0`. - ## [2.17] - 2023-12-20 ### Added diff --git a/bin/compile b/bin/compile index 2195908..aa63f6c 100644 --- a/bin/compile +++ b/bin/compile @@ -11,8 +11,8 @@ set -o pipefail # set -x # Set agent pinned version -DD_AGENT_PINNED_VERSION_6="6.51.0-1" -DD_AGENT_PINNED_VERSION_7="7.51.0-1" +DD_AGENT_PINNED_VERSION_6="6.52.0-1" +DD_AGENT_PINNED_VERSION_7="7.52.0-1" # Parse and derive params BUILD_DIR=$1 @@ -27,6 +27,10 @@ else CACHED_STACK=$STACK fi +version_equal_or_newer() { + [ "$1" == "$(echo -e "$1\n$2" | sort -V | tail -n1)" ] +} + # Ensure we store the STACK in the cache for next time. mkdir -p "$CACHE_DIR/.apt" echo "$STACK" > "$CACHE_DIR/.apt/STACK" @@ -34,15 +38,18 @@ echo "$STACK" > "$CACHE_DIR/.apt/STACK" # If a version hasn't been specified, use the pinned version if [ -f "$ENV_DIR/DD_AGENT_VERSION" ]; then DD_AGENT_VERSION=$(cat "$ENV_DIR/DD_AGENT_VERSION") + DD_AGENT_MAJOR_VERSION=$(echo $DD_AGENT_VERSION | cut -d'.' -f1) else if [ -f "$ENV_DIR/DD_AGENT_MAJOR_VERSION" ]; then DD_AGENT_MAJOR_VERSION=$(cat "$ENV_DIR/DD_AGENT_MAJOR_VERSION") if [ "$DD_AGENT_MAJOR_VERSION" == "6" ]; then DD_AGENT_VERSION="$DD_AGENT_PINNED_VERSION_6" else + DD_AGENT_MAJOR_VERSION="7" DD_AGENT_VERSION="$DD_AGENT_PINNED_VERSION_7" fi else + DD_AGENT_MAJOR_VERSION="7" DD_AGENT_VERSION="$DD_AGENT_PINNED_VERSION_7" fi fi @@ -101,9 +108,7 @@ done # Prior to Agent 6.14 there was only 1 python version DD_AGENT_BASE_VERSION="6.14" -if [ "$DD_AGENT_VERSION" == "$(echo -e "$DD_AGENT_BASE_VERSION\n$DD_AGENT_VERSION" | sort -V | head -n1)" ]; then - DD_PYTHON_VERSION="2" -else +if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then if [ -f "$ENV_DIR/DD_PYTHON_VERSION" ]; then DD_PYTHON_VERSION=$(cat "$ENV_DIR/DD_PYTHON_VERSION") if [ "$DD_PYTHON_VERSION" != "2" ] && [ "$DD_PYTHON_VERSION" != "3" ]; then @@ -114,11 +119,13 @@ else else DD_PYTHON_VERSION="2" # if not specified, we default to Python 2 fi +else + DD_PYTHON_VERSION="2" fi # Agent 7 onwards is Python3 only and repo file is different DD_AGENT_BASE_VERSION="7" -if [ "$DD_AGENT_VERSION" != "$(echo -e "$DD_AGENT_BASE_VERSION\n$DD_AGENT_VERSION" | sort -V | head -n1)" ]; then +if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then DD_PYTHON_VERSION="3" # Modify repo file to point to agent 7 cp "$APT_REPO_FILE_7" "$APT_REPO_FILE" @@ -225,16 +232,33 @@ if [ -f "$ENV_DIR/DD_APM_ENABLED" ]; then fi fi +if [ "$DD_AGENT_MAJOR_VERSION" == "6" ]; then + DD_AGENT_BASE_VERSION="6.52.0" +else + DD_AGENT_BASE_VERSION="7.52.0" +fi + # If the process agent hasn't been explicitly enabled, delete the agent if [ -f "$ENV_DIR/DD_PROCESS_AGENT" ]; then DD_PROCESS_AGENT=$(cat "$ENV_DIR/DD_PROCESS_AGENT") if [ "$DD_PROCESS_AGENT" == "false" ]; then topic "DD_PROCESS_AGENT set to false. Removing the process agent." rm -rf "$APT_DIR/opt/datadog-agent/embedded/bin/process-agent" + # starting on 7.52.0, there is a binary of core+process agent + if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then + mv -f "$APT_DIR/opt/datadog-agent/bin/agent/core-agent" "$APT_DIR/opt/datadog-agent/bin/agent/agent" + fi + else + if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then + rm -rf "$APT_DIR/opt/datadog-agent/bin/agent/core-agent" + fi fi else topic "DD_PROCESS_AGENT not set. Removing the process agent." rm -rf "$APT_DIR/opt/datadog-agent/embedded/bin/process-agent" + if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then + mv -f "$APT_DIR/opt/datadog-agent/bin/agent/core-agent" "$APT_DIR/opt/datadog-agent/bin/agent/agent" + fi fi # We remove the unneeded version of Python diff --git a/extra/datadog.sh b/extra/datadog.sh index b5fce30..6438b74 100644 --- a/extra/datadog.sh +++ b/extra/datadog.sh @@ -37,6 +37,10 @@ sed -i -e"s|^.*additional_checksd:.*$|additional_checksd: $DD_CONF_DIR/checks.d\ # Update the Datadog conf yaml to disable cloud provider metadata sed -i -e"s|^.*cloud_provider_metadata:.*$|cloud_provider_metadata: []|" "$DATADOG_CONF" +version_equal_or_newer() { + [ "$1" == "$(echo -e "$1\n$2" | sort -V | tail -n1)" ] +} + # Include application's datadog configs APP_DATADOG_DEFAULT="/app/datadog" APP_DATADOG="${DD_HEROKU_CONF_FOLDER:=$APP_DATADOG_DEFAULT}" @@ -73,7 +77,7 @@ done # Add tags to the config file DYNOHOST="$(hostname )" DYNOTYPE=${DYNO%%.*} -BUILDPACKVERSION="dev" +BUILDPACKVERSION="2.19" DYNO_TAGS="dyno:$DYNO dynotype:$DYNOTYPE buildpackversion:$BUILDPACKVERSION" # We want always to have the Dyno ID as a host alias to improve correlation @@ -142,6 +146,10 @@ fi PYTHON_DIR=$(find "$DD_DIR/embedded/lib/" -maxdepth 1 -type d -regex ".*/python[2-3]\.[0-9]+" -printf "%f") DD_PYTHON_VERSION=$(echo $PYTHON_DIR | sed -n -E 's/^python([2-3])\.[0-9]+/\1/p') +# Get agent versions +DD_AGENT_VERSION=$(agent-wrapper version | cut -d " " -f2) +DD_AGENT_MAJOR_VERSION=$(echo $DD_AGENT_VERSION | cut -d'.' -f1) + if [ "$DD_PYTHON_VERSION" = "3" ]; then # This is not needed for Agent7 onwards, as it only has one Python version DD_AGENT_BASE_VERSION="7" @@ -349,11 +357,22 @@ else bash -c "PYTHONPATH=\"$DD_PYTHONPATH\" LD_LIBRARY_PATH=\"$DD_LD_LIBRARY_PATH\" $DD_DIR/embedded/bin/trace-agent -config $DATADOG_CONF 2>&1 &" fi + if [ "$DD_AGENT_MAJOR_VERSION" == "6" ]; then + DD_AGENT_BASE_VERSION="6.52.0" + else + DD_AGENT_BASE_VERSION="7.52.0" + fi # The Process Agent must be run explicitly if [ "$DD_PROCESS_AGENT" == "true" ]; then if [ "$DD_LOG_LEVEL_LOWER" == "debug" ]; then echo "Starting Datadog Process Agent on $DD_HOSTNAME" fi - bash -c "PYTHONPATH=\"$DD_PYTHONPATH\" LD_LIBRARY_PATH=\"$DD_LD_LIBRARY_PATH\" $DD_DIR/embedded/bin/process-agent -config $DATADOG_CONF 2>&1 &" + # Starting on Agent 7.52.0, the process agent is included in the agent binary + if version_equal_or_newer $DD_AGENT_VERSION $DD_AGENT_BASE_VERSION; then + ln -sfn "$DD_BIN_DIR"/agent "$DD_BIN_DIR"/process-agent + bash -c "PYTHONPATH=\"$DD_PYTHONPATH\" LD_LIBRARY_PATH=\"$DD_LD_LIBRARY_PATH\" $DD_BIN_DIR/process-agent -config $DATADOG_CONF 2>&1 &" + else + bash -c "PYTHONPATH=\"$DD_PYTHONPATH\" LD_LIBRARY_PATH=\"$DD_LD_LIBRARY_PATH\" $DD_DIR/embedded/bin/process-agent -config $DATADOG_CONF 2>&1 &" + fi fi fi