| 1 | #!/bin/sh |
| 2 | |
| 3 | real_pytest="" |
| 4 | old_ifs="${IFS}" |
| 5 | IFS=: |
| 6 | for path_dir in ${PATH}; do |
| 7 | path_dir="${path_dir:-.}" |
| 8 | case ":${CI_INFRA_OTEL_SHIM_PATHS:-}:" in |
| 9 | *":${path_dir}:"*) continue ;; |
| 10 | esac |
| 11 | if [ -x "${path_dir}/pytest" ]; then |
| 12 | real_pytest="${path_dir}/pytest" |
| 13 | break |
| 14 | fi |
| 15 | done |
| 16 | IFS="${old_ifs}" |
| 17 | |
| 18 | if [ -z "${real_pytest}" ]; then |
| 19 | echo "vLLM CI OTel: pytest executable not found" >&2 || : |
| 20 | exit 127 |
| 21 | fi |
| 22 | |
| 23 | helper_dir="${CI_INFRA_OTEL_DIR:-}" |
| 24 | otel_pythonpath="${helper_dir}${PYTHONPATH:+:${PYTHONPATH}}" |
| 25 | otel_available() { |
| 26 | if command -v timeout >/dev/null 2>&1; then |
| 27 | timeout 2s env PYTHONPATH="${otel_pythonpath}" python3 -c "import ci_otel" \ |
| 28 | >/dev/null 2>&1 |
| 29 | else |
| 30 | PYTHONPATH="${otel_pythonpath}" python3 -c "import ci_otel" >/dev/null 2>&1 |
| 31 | fi |
| 32 | } |
| 33 | |
| 34 | if [ -n "${helper_dir}" ] && |
| 35 | [ -n "${CI_INFRA_TRACE_ID:-}" ] && |
| 36 | [ -n "${CI_INFRA_COMMAND_SPAN_ID:-}" ] && |
| 37 | otel_available; then |
| 38 | PYTHONPATH="${otel_pythonpath}" exec "${real_pytest}" -p ci_otel "$@" |
| 39 | fi |
| 40 | |
| 41 | echo "vLLM CI OTel: pytest tracing skipped; running pytest normally" >&2 || : |
| 42 | exec "${real_pytest}" "$@" |