From ead59ac7ffa9a79117db660932b14d363675e35c Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Thu, 15 Oct 2020 15:31:32 +0100 Subject: [PATCH] Expose BPLOG_PREFIX to sub-shells again (#1099) In #1011 the number of buildpack variables that are exported (and so exposed to subprocesses) was reduced, since in general we don't want to leak buildpack internals into end-user steps such as the pre/post compile hooks. However since this change, any buildpack metric emitted from within a `sub_env` wrapper (which is a buildpack-stdlib utility function) is missing its `buildpack.python` prefix. This is because buildpack-stdlib: * lazy-loads `BPLOG_PREFIX` (rather than doing so when initially sourced, which is the approach used for `BUILDPACK_LOG_FILE`) * doesn't check whether `BPLOG_PREFIX` is set before emitting metrics See: https://github.com/heroku/buildpack-stdlib/blob/v8/stdlib.sh As a stop-gap until we either fix this in buildpack-stdlib (W-8095466), or remove usages of the `sub_env` wrapper (since I think they are counter-productive in this buildpack), I've added back the export for `BPLOG_PREFIX`. Fixes @W-8095436@. --- CHANGELOG.md | 1 + bin/compile | 2 +- test/run-features | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a90fc02..06c14aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ## v183 (2020-10-12) - Add support for Heroku-20 (#968). +- Fix metric names for metrics emitted within `sub_env` (#1099). ## v182 (2020-10-06) diff --git a/bin/compile b/bin/compile index 2054a29..c81e97b 100755 --- a/bin/compile +++ b/bin/compile @@ -18,7 +18,7 @@ set -eo pipefail # Boostrap the Buildpack Standard Library. # Disable unused env var warning since shellcheck doesn't know about the stdlib. # shellcheck disable=2034 -BPLOG_PREFIX="buildpack.python" +export BPLOG_PREFIX="buildpack.python" export BUILDPACK_LOG_FILE=${BUILDPACK_LOG_FILE:-/dev/null} [ "$BUILDPACK_XTRACE" ] && set -o xtrace diff --git a/test/run-features b/test/run-features index a873788..7496854 100755 --- a/test/run-features +++ b/test/run-features @@ -116,6 +116,7 @@ testHooks() { local expected_env_vars=( _ BIN_DIR + BPLOG_PREFIX BUILD_DIR BUILDPACK_LOG_FILE CACHE_DIR