Skip to content

Commit

Permalink
Add additional buildpack metrics
Browse files Browse the repository at this point in the history
Covering:
- use of outdated Python patch versions
- any occurrences of internal errors

(Split out of the upcoming Python version refactor for easier review)
  • Loading branch information
edmorley committed Oct 7, 2024
1 parent f29d3dc commit 78fee12
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

- Added support for Python 3.9 on Heroku-24. ([#1656](https://github.com/heroku/heroku-buildpack-python/pull/1656))
- Added buildpack metrics for use of outdated Python patch versions and occurrences of internal errors. ([#1657](https://github.com/heroku/heroku-buildpack-python/pull/1657))
- Improved the robustness of buildpack error handling by enabling `inherit_errexit`. ([#1655](https://github.com/heroku/heroku-buildpack-python/pull/1655))

## [v258] - 2024-10-01
Expand Down
12 changes: 6 additions & 6 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ else
CACHED_PYTHON_STACK=$STACK
fi

PACKAGE_MANAGER=$(package_manager::determine_package_manager "${BUILD_DIR}")
meta_set "package_manager" "${PACKAGE_MANAGER}"
package_manager=$(package_manager::determine_package_manager "${BUILD_DIR}")
meta_set "package_manager" "${package_manager}"

# Pipenv Python version support.
# Detect the version of Python requested from a Pipfile (e.g. python_version or python_full_version).
Expand Down Expand Up @@ -189,7 +189,7 @@ meta_time "python_install_duration" "${install_python_start_time}"
# Install the package manager and related tools.
package_manager_install_start_time=$(nowms)
bundled_pip_module_path="$(utils::bundled_pip_module_path "${BUILD_DIR}")"
case "${PACKAGE_MANAGER}" in
case "${package_manager}" in
pip)
pip::install_pip_setuptools_wheel "${bundled_pip_module_path}"
;;
Expand All @@ -199,7 +199,7 @@ case "${PACKAGE_MANAGER}" in
pipenv::install_pipenv
;;
*)
utils::abort_internal_error "Unhandled package manager"
utils::abort_internal_error "Unhandled package manager: ${package_manager}"
;;
esac
meta_time "package_manager_install_duration" "${package_manager_install_start_time}"
Expand All @@ -214,15 +214,15 @@ meta_time "sqlite_install_duration" "${install_sqlite_start_time}"

# Install app dependencies.
dependencies_install_start_time=$(nowms)
case "${PACKAGE_MANAGER}" in
case "${package_manager}" in
pip)
pip::install_dependencies
;;
pipenv)
pipenv::install_dependencies
;;
*)
utils::abort_internal_error "Unhandled package manager"
utils::abort_internal_error "Unhandled package manager: ${package_manager}"
;;
esac
meta_time "dependencies_install_duration" "${dependencies_install_start_time}"
Expand Down
1 change: 1 addition & 0 deletions bin/report
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ ALL_OTHER_FIELDS=(
pre_compile_hook
pre_compile_hook_duration
python_install_duration
python_version_outdated
setup_py_only
sqlite_install_duration
total_duration
Expand Down
3 changes: 3 additions & 0 deletions bin/steps/python
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ function warn_if_patch_update_available() {
puts-warn "A Python security update is available! Upgrade as soon as possible to: ${latest_patch_version}"
puts-warn "See: https://devcenter.heroku.com/articles/python-runtimes"
puts-warn
meta_set "python_version_outdated" "true"
else
meta_set "python_version_outdated" "false"
fi
}

Expand Down
1 change: 1 addition & 0 deletions lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ function utils::bundled_pip_module_path() {
function utils::abort_internal_error() {
local message="${1}"
display_error "Internal error: ${message} (line $(caller || true))."
meta_set "failure_reason" "internal-error"
exit 1
}

0 comments on commit 78fee12

Please sign in to comment.