Skip to content

Commit

Permalink
Add some log embedded metrics to ci jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Dec 5, 2023
1 parent 1f798d9 commit 607c81f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .gitlab/gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ variables:
download:
stage: .pre
script:
- go mod download
- |
start=$(date +%s%N)
go mod download
end=$(date +%s%N)
duration=$(printf %.6f "$(( end-start ))e-9")
timestamp=$(( end/1000000 ))
module=$(head -n 1 go.mod | cut -d ' ' -f 2)
echo "METRIC_go_mod_download_time{module=\"${module}\"} ${duration} ${timestamp}"
cache: &cache-defaults
key: ${CI_COMMIT_REF_SLUG}
paths:
Expand All @@ -39,7 +46,13 @@ build:
- <<: *cache-defaults
policy: pull
script:
- go build .
- |
start=$(date +%s%N)
go build .
end=$(date +%s%N)
duration=$(printf %.6f "$(( end-start ))e-9")
timestamp=$(( end/1000000 ))
echo "METRIC_go_build_time{package=\"$(go list .)\"} ${duration} ${timestamp}"
test:
stage: test
Expand All @@ -50,6 +63,8 @@ test:
- go install gotest.tools/gotestsum@latest
script:
- ${GOPATH}/bin/gotestsum --junitfile report.xml --format testname ./test/...
after_script:
- go run ./tools/junitmetrics ./report.xml
artifacts:
when: always
reports:
Expand Down

0 comments on commit 607c81f

Please sign in to comment.