diff --git a/lib/run-datadog.sh b/lib/run-datadog.sh index b6e3a9b..2407914 100644 --- a/lib/run-datadog.sh +++ b/lib/run-datadog.sh @@ -233,5 +233,22 @@ main() { exec 9>&- fi fi + + # wait for the trace agent startup + if [ "${WAIT_DD_TRACE_AGENT}" = "true" ]; then + timeout=120 + while ! nc -z localhost 8126 && [ $timeout -ge 0 ]; do + echo "Waiting for the trace agent to start on 8126..." + sleep 1 + timeout=$((timeout - 1)) + done + if [ $timeout -ge 0 ]; then + echo "Trace agent is listening for traces" + else + echo "Timed out waiting for the trace agent" + fi + fi } main "$@" + +