Skip to content

Commit a5dfa07

Browse files
authored
Add additional buildpack metrics (#1657)
Covering: - use of outdated Python patch versions - any occurrences of internal errors (Split out of the upcoming Python version refactor for easier review)
1 parent f29d3dc commit a5dfa07

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [Unreleased]
44

55
- Added support for Python 3.9 on Heroku-24. ([#1656](https://github.com/heroku/heroku-buildpack-python/pull/1656))
6+
- 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))
67
- Improved the robustness of buildpack error handling by enabling `inherit_errexit`. ([#1655](https://github.com/heroku/heroku-buildpack-python/pull/1655))
78

89
## [v258] - 2024-10-01

bin/compile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ else
137137
CACHED_PYTHON_STACK=$STACK
138138
fi
139139

140-
PACKAGE_MANAGER=$(package_manager::determine_package_manager "${BUILD_DIR}")
141-
meta_set "package_manager" "${PACKAGE_MANAGER}"
140+
package_manager="$(package_manager::determine_package_manager "${BUILD_DIR}")"
141+
meta_set "package_manager" "${package_manager}"
142142

143143
# Pipenv Python version support.
144144
# Detect the version of Python requested from a Pipfile (e.g. python_version or python_full_version).
@@ -189,7 +189,7 @@ meta_time "python_install_duration" "${install_python_start_time}"
189189
# Install the package manager and related tools.
190190
package_manager_install_start_time=$(nowms)
191191
bundled_pip_module_path="$(utils::bundled_pip_module_path "${BUILD_DIR}")"
192-
case "${PACKAGE_MANAGER}" in
192+
case "${package_manager}" in
193193
pip)
194194
pip::install_pip_setuptools_wheel "${bundled_pip_module_path}"
195195
;;
@@ -199,7 +199,7 @@ case "${PACKAGE_MANAGER}" in
199199
pipenv::install_pipenv
200200
;;
201201
*)
202-
utils::abort_internal_error "Unhandled package manager"
202+
utils::abort_internal_error "Unhandled package manager: ${package_manager}"
203203
;;
204204
esac
205205
meta_time "package_manager_install_duration" "${package_manager_install_start_time}"
@@ -214,15 +214,15 @@ meta_time "sqlite_install_duration" "${install_sqlite_start_time}"
214214

215215
# Install app dependencies.
216216
dependencies_install_start_time=$(nowms)
217-
case "${PACKAGE_MANAGER}" in
217+
case "${package_manager}" in
218218
pip)
219219
pip::install_dependencies
220220
;;
221221
pipenv)
222222
pipenv::install_dependencies
223223
;;
224224
*)
225-
utils::abort_internal_error "Unhandled package manager"
225+
utils::abort_internal_error "Unhandled package manager: ${package_manager}"
226226
;;
227227
esac
228228
meta_time "dependencies_install_duration" "${dependencies_install_start_time}"

bin/report

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ ALL_OTHER_FIELDS=(
8686
pre_compile_hook
8787
pre_compile_hook_duration
8888
python_install_duration
89+
python_version_outdated
8990
setup_py_only
9091
sqlite_install_duration
9192
total_duration

bin/steps/pipenv-python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Detect Python-version with Pipenv.
88

9-
if [[ "${PACKAGE_MANAGER}" == "pipenv" ]]; then
9+
if [[ "${package_manager}" == "pipenv" ]]; then
1010

1111
if [[ ! -f $BUILD_DIR/runtime.txt ]]; then
1212
if [[ ! -f $BUILD_DIR/Pipfile.lock ]]; then

bin/steps/python

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ function warn_if_patch_update_available() {
7676
puts-warn "A Python security update is available! Upgrade as soon as possible to: ${latest_patch_version}"
7777
puts-warn "See: https://devcenter.heroku.com/articles/python-runtimes"
7878
puts-warn
79+
meta_set "python_version_outdated" "true"
80+
else
81+
meta_set "python_version_outdated" "false"
7982
fi
8083
}
8184

lib/utils.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ function utils::bundled_pip_module_path() {
2929
function utils::abort_internal_error() {
3030
local message="${1}"
3131
display_error "Internal error: ${message} (line $(caller || true))."
32+
meta_set "failure_reason" "internal-error"
3233
exit 1
3334
}

0 commit comments

Comments
 (0)