Skip to content

Commit

Permalink
Measure seconds since last push directly
Browse files Browse the repository at this point in the history
Don't push the datetime as a metric, since that's annoying to parse and
process in Grafana.

"waittime" is the time between push and pick-up for pr_processing events, and
time time between push and check completion for pr_processing_done events.
  • Loading branch information
TimoWilken committed Nov 27, 2023
1 parent 5bae93d commit ecce0e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ci/build-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function report_state () {
${NUM_BASE_COMMITS:+"num_base_commits=$NUM_BASE_COMMITS"} \
-- "host=\"$(hostname -s)\"" "state=\"$current_state\"" \
"prid=\"$PR_NUMBER\"" ${prtime:+prtime=$prtime} ${PR_OK:+prok=$PR_OK} \
${LAST_PUSH_TIME:+push=$LAST_PUSH_TIME} \
${LAST_PUSH_TIME:+waittime=$((time_now - LAST_PUSH_TIME))} \
${HAVE_JALIEN_TOKEN:+have_jalien_token=$HAVE_JALIEN_TOKEN}

# Push to Google Analytics if configured
Expand Down
19 changes: 11 additions & 8 deletions list-branch-pr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import sys

from argparse import ArgumentParser
from collections import defaultdict
from datetime import datetime

from gql import Client, gql
from gql.transport.requests import RequestsHTTPTransport
Expand Down Expand Up @@ -179,16 +180,15 @@ class RepoConfig:
("succeeded" if success else "failed")
else:
state = "skip"
print("pr: {number:6d}@{sha:.7s}: revd={reviewed:d} trust={trust:d} "
"tested={tested:d} success={success:d} => state={state}".format(
number=pull_number, sha=commit_hash, reviewed=reviewed,
trust=is_trusted, tested=tested, success=success, state=state
), file=sys.stderr)
updated_time = last_commit["pushedDate"]
print(f"pr: {pull_number:6d}@{commit_hash:.7s}: upd={updated_time:s} "
f"revd={reviewed:d} trust={is_trusted:d} tested={tested:d} "
f"success={success:d} => state={state}", file=sys.stderr)
return None if state == "skip" else (state, {
"number": pull_number,
"sha": commit_hash,
"build_config": self.build_config,
"updated_at": last_commit["pushedDate"],
"updated_at": updated_time,
})

def process_pulls(self, session, repo_info, show_base_branch=False):
Expand Down Expand Up @@ -258,8 +258,11 @@ def main(args):
# pr["updated_at"] can apparently be None sometimes, which breaks
# sorting, so default to the empty string if so.
for pull in sorted(prs, key=lambda pr: pr["updated_at"] or ""):
print(group, pull["number"], pull["sha"],
pull["build_config"], pull["updated_at"], sep="\t")
last_push_timestamp = \
int(datetime.fromisoformat(pull["updated_at"]).timestamp) \
if pull["updated_at"] else int(datetime.utcnow().timestamp)
print(group, pull["number"], pull["sha"], pull["build_config"],
last_push_timestamp, sep="\t")

if grouped["untested"]:
# If there are untested PRs waiting, build all of them first.
Expand Down

0 comments on commit ecce0e0

Please sign in to comment.