Skip to content
This repository has been archived by the owner on Dec 2, 2018. It is now read-only.

Add support for Datadog APM #28

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
Next Next commit
Add DD_ var name support, add APM support
  • Loading branch information
jyee committed Mar 17, 2017
commit 8d295acef189d468a1fa0a7e5a31f630ae1dcd11
45 changes: 37 additions & 8 deletions extra/run-dogstatsd.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
#!/bin/bash

if [[ $DATADOG_API_KEY ]]; then
sed -i -e "s/^.*api_key:.*$/api_key: ${DATADOG_API_KEY}/" /app/.apt/opt/datadog-agent/agent/datadog.conf
# Prefered Datadog env var name
if [[ $DD_API_KEY ]]; then
sed -i -e "s/^[# ]*api_key:.*$/api_key: ${DD_API_KEY}/" /app/.apt/opt/datadog-agent/agent/datadog.conf
# Legacy env var support
elif [[ $DATADOG_API_KEY ]]; then
sed -i -e "s/^[# ]*api_key:.*$/api_key: ${DATADOG_API_KEY}/" /app/.apt/opt/datadog-agent/agent/datadog.conf
else
echo "DATADOG_API_KEY environment variable not set. Run: heroku config:add DATADOG_API_KEY=<your API key>"
echo "DD_API_KEY environment variable not set. Run: heroku config:add DD_API_KEY=<your API key>"
exit 1
fi

if [[ $HEROKU_APP_NAME ]]; then
sed -i -e "s/^.*hostname:.*$/hostname: ${HEROKU_APP_NAME}/" /app/.apt/opt/datadog-agent/agent/datadog.conf
# Prefered Datadog env var name
if [[ $DD_HOSTNAME ]]; then
sed -i -e "s/^[# ]*hostname:.*$/hostname: ${DD_HOSTNAME}/" /app/.apt/opt/datadog-agent/agent/datadog.conf
# Legacy env var support
elif [[ $HEROKU_APP_NAME ]]; then
sed -i -e "s/^[# ]*hostname:.*$/hostname: ${HEROKU_APP_NAME}/" /app/.apt/opt/datadog-agent/agent/datadog.conf
else
echo "HEROKU_APP_NAME environment variable not set. Run: heroku apps:info|grep ===|cut -d' ' -f2"
echo "DD_HOSTNAME environment variable not set. Run: heroku config:set DD_HOSTNAME=$(heroku apps:info|grep ===|cut -d' ' -f2)"
exit 1
fi

if [[ $DATADOG_HISTOGRAM_PERCENTILES ]]; then
sed -i -e "s/^.*histogram_percentiles:.*$/histogram_percentiles: ${DATADOG_HISTOGRAM_PERCENTILES}/" /app/.apt/opt/datadog-agent/agent/datadog.conf

if [[ $DD_APM_ENABLED == "true" ]]; then
sed -i -e "s/^[# ]*apm_enabled:.*$/apm_enabled: true/" /app/.apt/opt/datadog-agent/agent/datadog.conf
echo "apm_enabled: true" >> /app/.apt/opt/datadog-agent/agent/datadog.conf
fi

# Prefered Datadog env var name
if [[ $DD_HISTOGRAM_PERCENTILES ]]; then
sed -i -e "s/^[# ]*histogram_percentiles:.*$/histogram_percentiles: ${DD_HISTOGRAM_PERCENTILES}/" /app/.apt/opt/datadog-agent/agent/datadog.conf
# Legacy env var support
elif [[ $DATADOG_HISTOGRAM_PERCENTILES ]]; then
sed -i -e "s/^[# ]*histogram_percentiles:.*$/histogram_percentiles: ${DATADOG_HISTOGRAM_PERCENTILES}/" /app/.apt/opt/datadog-agent/agent/datadog.conf
fi

(
Expand All @@ -30,3 +48,14 @@ fi
exec /app/.apt/opt/datadog-agent/embedded/bin/python /app/.apt/opt/datadog-agent/agent/dogstatsd.py start
fi
)

(
if [[ $DISABLE_DATADOG_AGENT ]]; then
echo "DISABLE_DATADOG_AGENT environment variable is set, not starting the tracing agent."
else
# Enable the trace agent
if [[ $DD_APM_ENABLED == "true" ]]; then
exec /app/.apt/opt/datadog-agent/bin/trace-agent -ddconfig /app/.apt/opt/datadog-agent/agent/datadog.conf -debug >> /tmp/logs/datadog/trace-agent.log 2>&1 &
fi
fi
)