HewlettPackard/zing-stats

Name: zing-stats

Owner: Hewlett Packard Enterprise

Description: Tool for generating summary stat reports and graphs from Gerrit (https://www.gerritcodereview.com/) and GitHub Enterprise review and pull requests data using https://plot.ly/.

Created: 2017-08-30 13:47:21.0

Updated: 2018-05-10 07:51:00.0

Pushed: 2018-05-01 13:25:40.0

Homepage:

Size: 278

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status Docker Automated build

© Copyright 2017 Hewlett Packard Enterprise Development LP

zing-stats

Introduction

Tool for generating summary stat reports and graphs from Gerrit (https://www.gerritcodereview.com/) and GitHub Enterprise review and pull requests data.

Terminology:

For now, zing-stats expects job comments in the format printed by OpenStack Zuul. This needs to be more customisable in future. For now, if your CI system uses a different format, you'll need to modify the hardcoded regexs.

Screenshots

Example output with projects tab (–project-map specified) Screenshot #1

Example output where CI jobs include duration info Screenshot #2

Example output without projects (no projects tabs) Screenshot #3

Example output of detailed stats section Screenshot #4

Installation
Using virtualenv
clone <url to zing-stats repo>
 apt install virtualenv
ualenv ~/venv/zing-stats
venv/zing-stats/bin/activate
install -r requirements.txt
Running
Running as script
ng_stats.py --gerrit-url <gerrit url> --github-url <github enterprise url> --github-token <github token> -o <output directory>

The team names used in zing-stats reports are read from projects.json

Running from docker hub

(assumes projects.json is in your pwd, adjust the -v as neccesary if not)

er run -v $(pwd)/projects.json:/projects.json -e GERRIT_URL=<gerrit url> -e GITHUB_URL=<github enterprise url> -e GITHUB_TOKEN=<github token> zingstats/zing-stats

e.g.

er run -v $(pwd)/projects.json:/projects.json -e gerrit_host=https://review.openstack.org/ -e github_host=https://github.com/ zingstats/zing-stats
Running in docker compose

Uses docker compose to stand up dedicated containers for generation and reporting.

  1. Build the environment,
    er-compose build --force-rm --no-cache
    
  2. Create a docker-compose environment file (zing_stats.env) with your zing-stats arguments e.g.
    IT_URL=https://gerrit.example.net
    UB_URL=https://github.example.net
    UB_TOKEN=345sdfe
    _PROJECTS=/var/tmp/projects.json
    
  3. Run the environment (detached)
    er-compose up -d
    
  4. Attach to running container
    er-compose exec zing-stats /bin/bash
    er-compose exec zing-stats-web /bin/ash
    
  5. zing-stats output at http://localhost:8172/last_7d/ (may take some time depending on number of configured projects)
Testing
on setup.py test
Design

General strategy

  1. Pull changes data from Gerrit (or a file)
  2. Load data into Pandas DataFrames
  3. Restrict to range of interest
  4. Resample to days or hours
  5. Extract stats (count, min, max, avg and so on)
  6. Tabulate and plot
Roadmap / Potential TODO
  1. Verify against public Gerrit instances
  2. Improve testing
  3. Improve setup config
  4. Investigate use of Pandas Panels (deprecated) or MultiIndex instead of lots of DataFrames.
  5. Add statistics for jobs run (we collect this data, just a case of assembling it)
  6. Add in highlighting of out of bounds values in the html report e.g. excessive failure rates in red
  7. Other reports/stats requested:
    • how long changes are queued before getting a ci run (may need to query Zuul for this)
    • ci system utilisation/capacity (used total ci hours in the past here, alternative is to aggregate cpu/memory usage stats from the systems)
    • number of Zuul gate queue resets for a change (may need to query Zuul for this)
  8. Job duration handling may only work for some Gerrit instances for now, need to determine if better way of gathering that.
  9. CI capacity stat relies on job duration data, so this is also unavailable on some Gerrit instances.
License

This project is licensed under the Apache 2.0 license. Please see LICENSE for more info.

Contributing and feature requests

Contributing: You know the drill. Fork it, branch it, change it, commit it, and pull-request it. We are passionate about improving this project, and glad to accept help to make it better. However, keep the following in mind:

Feature Requests: If you have a need that is not met by the current implementation, please let us know (via a new issue). This feedback is crucial for us to deliver a useful product. Do not assume we have already thought of everything, because we assure you that is not the case.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.