Add view-release-stats utility to see lead time by release and in window#28
Add view-release-stats utility to see lead time by release and in window#28jessemortenson wants to merge 2 commits intomainfrom
Conversation
| logger.log(logging.INFO, f"{release['tag_name']} on {release_date_in_utc} by {release['author']['login']}") | ||
|
|
||
| if (last_release): | ||
| commit_times_output = subprocess.check_output( |
There was a problem hiding this comment.
This step should be a function in github_stats/gitops.py to:
- leverage the existing auth that we're using with pygit2
- make the pattern consistent
- allow for more consistent error handling
| delta_in_minutes = get_time_delta_in_minutes_from_iso_strings(release_date_in_utc, commit_time) | ||
| deltas_in_minutes.append(delta_in_minutes) | ||
| total_delta += delta_in_minutes | ||
| release_average_delta_in_hours = round(total_delta / 60 / len(commit_times)) |
There was a problem hiding this comment.
Magic numbers aren't great. If we can either add comments explaining them or use a variable instead...
| release_average_delta_in_hours = round(total_delta / 60 / len(commit_times)) | ||
| release_median_delta_in_hours = round(statistics.median(deltas_in_minutes) / 60) | ||
| lead_time_msg = "lead time for commit in release, in hours" | ||
| logger.log(logging.INFO, f"Average {lead_time_msg}: {release_average_delta_in_hours}") |
There was a problem hiding this comment.
logger.info instead of logger.log(logging.INFO, is the standard format for log messages.
| all_releases_total_delta_in_minutes = 0 | ||
| all_releases_total_commits = 0 | ||
| for release in releases: | ||
| release_date_in_utc = release['published_at'].rstrip('Z') + '+00:00' # datetime.fromisoformat hates the Z |
There was a problem hiding this comment.
We should see if another library doesn't hate the Z to avoid a brittle string comparison here.
| release_date_in_utc = release['published_at'].rstrip('Z') + '+00:00' # datetime.fromisoformat hates the Z | ||
| logger.log(logging.INFO, f"{release['tag_name']} on {release_date_in_utc} by {release['author']['login']}") | ||
|
|
||
| if (last_release): |
There was a problem hiding this comment.
No parentheses when there's no need.
| releases = [] | ||
| for release in gh.return_releases(timestamp, args.window): | ||
| releases.append(release) | ||
| releases.reverse() # Reverse so we have chronological |
There was a problem hiding this comment.
Could the return_releases function handle the reverse instead? Or even make that a switch (e.g. return_releases(timestamp, args.window, reverse=True)) that we could use?
| starttime = time.time() | ||
| gh = GithubAccess(local_config) | ||
| last_release = None | ||
| releases = [] |
There was a problem hiding this comment.
Could probably just be releases = return_releases(timestamp, args.window) instead of a loop.
|
Being re-worked in #35 |
Adds a utility script to view release statistics (eg lead time).
I wanted to examine some of the commit->release lead time by hand, to see what data in recent releases looks like and compare to the Average Time from Commit to Release stat we currently collect in Grafana.
Usage examples:
Also includes per-release output for each release in the window, like: