Skip to content

Commit 15c28ef

Browse files
committed
Drop lang-common S3 bucket dependency
This imports the relevant (to this buildpack) telemetry helper functions from https://lang-common.s3.us-east-1.amazonaws.com/buildpack-stdlib/v8/stdlib.sh GUS-W-13958512
1 parent bd5bdce commit 15c28ef

File tree

3 files changed

+55
-14
lines changed

3 files changed

+55
-14
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# heroku-buildpack-php CHANGELOG
22

3+
## v238 (2023-08-??)
4+
5+
### CHG
6+
7+
- Import telemetry helper shell functions previously vendored from 'lang-common' S3 bucket [David Zuelke]
8+
39
## v237 (2023-08-04)
410

511
### ADD

bin/compile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ source $bp_dir/bin/util/common.sh
2626
# we do not 'set -o errtrace', because that would cause subshell failures to fire the trap twice, e.g. with someval=$(func_that_fails)
2727
trap 'err_trap' ERR
2828

29-
# stdlib
30-
# download to a file first, as the function restarts the entire download on code 18 connection reset (not all servers support -C)
31-
curl_retry_on_18 --retry-connrefused --retry 3 --connect-timeout 5 --fail --silent --location -o $bp_dir/bin/util/stdlib.sh https://lang-common.s3.us-east-1.amazonaws.com/buildpack-stdlib/v8/stdlib.sh || {
32-
error <<-EOF
33-
Failed to download standard library for bootstrapping!
34-
35-
This is most likely a temporary internal error. If the problem
36-
persists, make sure that you are not running a custom or forked
37-
version of the Heroku PHP buildpack which may need updating.
38-
EOF
39-
}
40-
source $bp_dir/bin/util/stdlib.sh
41-
rm $bp_dir/bin/util/stdlib.sh
42-
4329
# failure counting
4430
source $bp_dir/bin/util/failures.sh
4531

bin/util/common.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,52 @@ err_trap() {
144144
)
145145
EOF
146146
}
147+
148+
# Logging
149+
# -------
150+
151+
# These functions expect BPLOG_PREFIX and BUILDPACK_LOG_FILE to be defined (BUILDPACK_LOG_FILE can point to /dev/null if not provided by the buildpack).
152+
# Example: BUILDPACK_LOG_FILE=${BUILDPACK_LOG_FILE:-/dev/null}; BPLOG_PREFIX="buildpack.go"
153+
154+
# Returns now, in milleseconds. Useful for logging.
155+
# Example: $ let start=$(nowms); sleep 30; mtime "glide.install.time" "${start}"
156+
nowms() {
157+
date +%s%3N
158+
}
159+
160+
# Measures time elapsed for a specific build step.
161+
# Usage: $ let start=$(nowms); mtime "glide.install.time" "${start}"
162+
# https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#distributions-measure
163+
mtime() {
164+
local key="${BPLOG_PREFIX}.${1}"
165+
local start="${2}"
166+
local end="${3:-$(nowms)}"
167+
echo "${key} ${start} ${end}" | awk '{ printf "measure#%s=%.3f\n", $1, ($3 - $2)/1000 }' >> "${BUILDPACK_LOG_FILE}"
168+
}
169+
170+
# Logs a count for a specific built step.
171+
# Usage: $ mcount "tool.govendor"
172+
# https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#counting-count
173+
mcount() {
174+
local k="${BPLOG_PREFIX}.${1}"
175+
local v="${2:-1}"
176+
echo "count#${k}=${v}" >> "${BUILDPACK_LOG_FILE}"
177+
}
178+
179+
# Logs a measure for a specific build step.
180+
# Usage: $ mmeasure "tool.installed_dependencies" 42
181+
# https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#distributions-measure
182+
mmeasure() {
183+
local k="${BPLOG_PREFIX}.${1}"
184+
local v="${2}"
185+
echo "measure#${k}=${v}" >> "${BUILDPACK_LOG_FILE}"
186+
}
187+
188+
# Logs a unuique measurement build step.
189+
# Usage: $ munique "versions.count" 2.7.13
190+
# https://github.com/heroku/engineering-docs/blob/master/guides/logs-as-data.md#uniques-unique
191+
munique() {
192+
local k="${BPLOG_PREFIX}.${1}"
193+
local v="${2}"
194+
echo "unique#${k}=${v}" >> "${BUILDPACK_LOG_FILE}"
195+
}

0 commit comments

Comments
 (0)