Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@ chmod +x "${DATADOG_DIR}/scripts/update_agent_config.sh"
cp "${ROOT_DIR}/lib/scripts/get_tags.rb" "${DATADOG_DIR}/scripts/get_tags.rb"


RUBY_CMD=ruby
RUBY_CMD=$DEPS_DIR/$DEPS_IDX/bin/ruby

# install ruby if needed (the case of cflinuxfs4 or custom stacks)
if ! which ruby > /dev/null; then
# Install the bundled Ruby for our scripts. Always done so the buildpack
# stops relying on the app's Ruby (which may not exist, or may be a
# different version on the chained ruby_buildpack).
if [ ! -x "${RUBY_CMD}" ]; then
echo "Installing Ruby"
tar -xzf "${ROOT_DIR}/lib/ruby_3.4.7.tgz" -C "$DEPS_DIR/$DEPS_IDX" && echo "Ruby Install finished"
export PATH=$PATH:/home/vcap/deps/$DEPS_IDX/bin
RUBY_CMD=$DEPS_DIR/$DEPS_IDX/bin/ruby
fi

# create a .global_env file to be sourced by external scripts
# for now, it appends the buildpack deps/bin folder to the PATH env variable of the caller
# this is needed for stacks where ruby is not installed since our scripts rely on it
echo "if ! which ruby > /dev/null; then
export PATH=\$PATH:/home/vcap/deps/$DEPS_IDX/bin
fi" > "$DATADOG_DIR/.global_env"
# Expose the bundled Ruby to runtime scripts via an absolute path rather
# than mutating PATH, so we don't shadow the app's own ruby/gem/bundle.
echo "export DD_RUBY=/home/vcap/deps/$DEPS_IDX/bin/ruby" > "$DATADOG_DIR/.global_env"

# for subsquent buildpacks and for buildpack metadata detection
echo "config: {}
Expand Down
19 changes: 8 additions & 11 deletions bin/supply
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@ chmod +x "${DATADOG_DIR}/scripts/update_agent_config.sh"
cp "${ROOT_DIR}/lib/scripts/get_tags.rb" "${DATADOG_DIR}/scripts/get_tags.rb"


RUBY_CMD=ruby
RUBY_CMD=$DEPS_DIR/$DEPS_IDX/bin/ruby

# install ruby if needed (the case of cflinuxfs4 or custom stacks)
if ! which ruby > /dev/null; then
# Install the bundled Ruby for our scripts. Always done so the buildpack
# stops relying on the app's Ruby (which may not exist, or may be a
# different version on the chained ruby_buildpack).
if [ ! -x "${RUBY_CMD}" ]; then
echo "Installing Ruby"
tar -xzf "${ROOT_DIR}/lib/ruby_3.4.7.tgz" -C "$DEPS_DIR/$DEPS_IDX" && echo "Ruby Install finished"
export PATH=$PATH:/home/vcap/deps/$DEPS_IDX/bin
RUBY_CMD=$DEPS_DIR/$DEPS_IDX/bin/ruby
fi

# create a .global_env file to be sourced by external scripts
# for now, it appends the buildpack deps/bin folder to the PATH env variable of the caller
# this is needed for stacks where ruby is not installed since our scripts rely on it
echo "if ! which ruby > /dev/null; then
export PATH=\$PATH:/home/vcap/deps/$DEPS_IDX/bin
fi" > "$DATADOG_DIR/.global_env"
# Expose the bundled Ruby to runtime scripts via an absolute path rather
# than mutating PATH, so we don't shadow the app's own ruby/gem/bundle.
echo "export DD_RUBY=/home/vcap/deps/$DEPS_IDX/bin/ruby" > "$DATADOG_DIR/.global_env"

# for subsquent buildpacks and for buildpack metadata detection
echo "config: {}
Expand Down
8 changes: 4 additions & 4 deletions lib/run-datadog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DD_RUN_AGENT="${DD_RUN_AGENT:-true}"
# source updated PATH
. "$DATADOG_DIR/.global_env"

export DD_TAGS=$(ruby "${DATADOG_DIR}/scripts/get_tags.rb")
export DD_TAGS=$("$DD_RUBY" "${DATADOG_DIR}/scripts/get_tags.rb")
echo "${DD_TAGS}" > "${DATADOG_DIR}/.dd_tags.txt"

setup_datadog() {
Expand Down Expand Up @@ -45,7 +45,7 @@ setup_datadog() {
if [ -n "${LOGS_CONFIG:-}" ]; then
mkdir -p "${LOGS_CONFIG_DIR}"
echo "creating logs config"
ruby "${DATADOG_DIR}/scripts/create_logs_config.rb"
"$DD_RUBY" "${DATADOG_DIR}/scripts/create_logs_config.rb"
fi

# The yaml file requires the tags to be an array,
Expand Down Expand Up @@ -111,15 +111,15 @@ setup_datadog() {
popd

# update datadog config
ruby "${DATADOG_DIR}/scripts/update_datadog_config.rb"
"$DD_RUBY" "${DATADOG_DIR}/scripts/update_datadog_config.rb"

# mark the script as finished, useful to sync the update_agent_config script
touch "${DATADOG_DIR}/.setup_completed"

}

start_datadog() {
export DD_TAGS=$(ruby "${DATADOG_DIR}/scripts/get_tags.rb")
export DD_TAGS=$("$DD_RUBY" "${DATADOG_DIR}/scripts/get_tags.rb")

pushd "${DATADOG_DIR}"
export DD_LOG_FILE="${DATADOG_DIR}/dogstatsd.log"
Expand Down
8 changes: 4 additions & 4 deletions lib/scripts/update_agent_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ release_lock() {
}

write_tags_to_file() {
export DD_TAGS=$(ruby "${DATADOG_DIR}"/scripts/get_tags.rb)
export DD_TAGS=$("$DD_RUBY" "${DATADOG_DIR}"/scripts/get_tags.rb)

export LOGS_CONFIG_DIR="${DATADOG_DIR}/dist/conf.d/logs.d"
export LOGS_CONFIG

log_info "Updating node_agent_tags.txt"
ruby "${DATADOG_DIR}/scripts/update_tags.rb"
"$DD_RUBY" "${DATADOG_DIR}/scripts/update_tags.rb"

# update datadog config
ruby "${DATADOG_DIR}/scripts/update_datadog_config.rb"
"$DD_RUBY" "${DATADOG_DIR}/scripts/update_datadog_config.rb"

if [ "${DD_ENABLE_CAPI_METADATA_COLLECTION}" = "true" ]; then
# update logs configs
if [ -n "${LOGS_CONFIG}" ]; then
mkdir -p "${LOGS_CONFIG_DIR}"
log_info "Updating logs config"
ruby "${DATADOG_DIR}/scripts/create_logs_config.rb"
"$DD_RUBY" "${DATADOG_DIR}/scripts/create_logs_config.rb"
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion lib/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ redirect() {
\"title\": \"Resetting buildpack log redirection\",
\"text\": \"TCP socket on port ${STD_LOG_COLLECTION_PORT:-} for log redirection closed. Restarting it.\",
\"priority\": \"normal\",
\"tags\": $(LEGACY_TAGS_FORMAT=true ruby "${DATADOG_DIR}/scripts/get_tags.rb"),
\"tags\": $(LEGACY_TAGS_FORMAT=true "$DD_RUBY" "${DATADOG_DIR}/scripts/get_tags.rb"),
\"alert_type\": \"info\"
}" "${DD_API_SITE:-}v1/events?api_key=${DD_API_KEY:-}"
fi
Expand Down
2 changes: 1 addition & 1 deletion lib/test-endpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if [ "${DD_LOGS_ENABLED:-}" = "true" ] && [ -n "${DD_LOGS_CONFIG_LOGS_DD_URL}" ]
\"title\": \"Log endpoint cannot be reached - Log collection not started\",
\"text\": \"Could not establish a connection to ${DD_LOGS_CONFIG_LOGS_DD_URL} after 5 seconds. Log collection has not been started.\",
\"priority\": \"normal\",
\"tags\": $(ruby "${DATADOG_DIR}"/scripts/get_tags.rb),
\"tags\": $("$DD_RUBY" "${DATADOG_DIR}"/scripts/get_tags.rb),
\"alert_type\": \"error\"
}" "api.${DD_SITE:-}/v1/events?api_key=${DD_API_KEY:-}"
else
Expand Down
Loading