Commit 4d741ea3 by Dominik Prokop Committed by GitHub

Build: Collect frontend build time metric (#20254)

parent 26c03066
......@@ -2,6 +2,8 @@
# shellcheck disable=SC2086
# shellcheck source=./scripts/helpers/exit-if-fail.sh
source "$(dirname "$0")/../helpers/exit-if-fail.sh"
#
# This script is executed from within the container.
#
......@@ -24,6 +26,16 @@ CCX64_MUSL=/tmp/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc
cd /go/src/github.com/grafana/grafana
echo "current dir: $(pwd)"
function reportFrontEndBuildTime() {
if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
# Only report for build job
# build-enterprise happens right after build on master
# so there is no need for reporting the same metric again
exit_if_fail ./scripts/ci-metrics-publisher.sh "grafana.ci-performance.frontend-build=$1"
fi
}
if [ "$CIRCLE_TAG" != "" ]; then
echo "Building releases from tag $CIRCLE_TAG"
OPT="-includeBuildId=false ${EXTRA_OPTS}"
......@@ -60,7 +72,11 @@ else
echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH"
fi
echo "Building frontend"
start=$(date +%s%N)
go run build.go ${OPT} build-frontend
runtime=$((($(date +%s%N) - start)/1000000))
echo "Frontent build took $runtime"
reportFrontEndBuildTime $runtime
if [ -d "dist" ]; then
rm -rf dist
......
......@@ -98,7 +98,11 @@ function build_frontend() {
fi
yarn install --pure-lockfile --no-progress
echo "Building frontend"
start=$(date +%s%N)
go run build.go ${OPT} build-frontend
runtime=$((($(date +%s%N) - start)/1000000))
echo "Frontent build took: $runtime ms"
echo "FRONTEND: finished"
}
......
......@@ -6,13 +6,23 @@ data=""
for ((i = 1; i <= $#; i++ )); do
remainder="${!i}"
first="${remainder%%=*}"; remainder="${remainder#*=}"
# Find everything until last = character (= is included in the result)
# This allows to add tags to metric names
metricName=$(grep -o "\(.*\)=" <<< $remainder)
# Get the metric value
value=${remainder#"$metricName"}
# Remove remaining = character from metric name
metricName=${metricName%?};
if [ -n "$data" ]; then
data="$data,"
fi
data=''$data'{"name": "'${first}'", "value": '${remainder}', "interval": 60, "mtype": "gauge", "time": '$(date +%s)'}'
data=''$data'{"name": "'${metricName}'", "value": '${value}', "interval": 60, "mtype": "gauge", "time": '$(date +%s)'}'
done
echo "Publishing metrics:"
echo "$data"
curl "https://6371:$GRAFANA_MISC_STATS_API_KEY@graphite-us-central1.grafana.net/metrics" \
-H 'Content-type: application/json' \
-d "[$data]"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment