diff --git a/scripts/build/build-all.sh b/scripts/build/build-all.sh index ed2aab4f342..63aa9878ea3 100755 --- a/scripts/build/build-all.sh +++ b/scripts/build/build-all.sh @@ -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 diff --git a/scripts/build/build.sh b/scripts/build/build.sh index 0a08e3f5c5c..2748f7283db 100755 --- a/scripts/build/build.sh +++ b/scripts/build/build.sh @@ -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" } diff --git a/scripts/ci-metrics-publisher.sh b/scripts/ci-metrics-publisher.sh index 463dd1471e6..6083b7a41af 100755 --- a/scripts/ci-metrics-publisher.sh +++ b/scripts/ci-metrics-publisher.sh @@ -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]"