|
1 | 1 | [](https://travis-ci.org/matchilling/github-metrics-graphite-exporter) |
2 | 2 |
|
3 | | -# Github PR Metrics Graphite Exporter |
| 3 | +# Github Pull Request Metrics |
4 | 4 |
|
5 | 5 | [](./data/github-pr-metrics.png) |
6 | 6 |
|
7 | | -This exporter converts raw GitHub pull request data to time series. The exported data points represent the number of seconds (⏰ business hours only, Mon-Fri 09:00 - 17:00) elapsed between the creation of the pull request and the merging of the pull request. |
| 7 | +This exporter converts raw GitHub pull request data to time series. The exported data points represent the number of seconds elapsed between the creation of the pull request and the merging of the pull request. |
8 | 8 |
|
9 | 9 | The timestamp is the creation time of the PR. |
10 | 10 |
|
11 | | -Exposed metrics name: `github.{USER_NAME}.{REPO_NAME}.pull_requests.time_to_merge` |
| 11 | +Exposed metrics name: `github.{GITHUB_USER_NAME}.{GITHUB_REPO_NAME}.pull_requests.time_to_merge` |
12 | 12 |
|
13 | 13 | ## Usage |
14 | 14 |
|
15 | 15 | ```sh |
16 | | -$ npm install |
| 16 | +# The user and repo name you want to collect and display metrics |
| 17 | +# e.g. https://github.com/facebook/react |
| 18 | +# GITHUB_USER_NAME=facebook |
| 19 | +# GITHUB_REPO_NAME=react |
| 20 | +$ export GITHUB_USER_NAME=github-user-name |
| 21 | +$ export GITHUB_REPO_NAME=github-repo-name |
| 22 | + |
| 23 | +# Create a personal access tokens (https://github.com/settings/tokens/new) |
| 24 | +$ export GITHUB_TOKEN=github-token |
| 25 | + |
| 26 | +# Path to the SQLite db file to store the collected data |
| 27 | +$ export DATABASE_PATH=data/github.db |
17 | 28 |
|
18 | | -# At the moment the user name & repo name are only used to build up the metrics path |
19 | | -$ export USER_NAME=github-user-name |
20 | | -$ export REPO_NAME=repository-name |
| 29 | +$ npm install |
21 | 30 |
|
22 | | -# Path to the SQLite db file containing the PR data retrieved from GitHub. |
23 | | -$ export PULL_REQUESTS_DATABASE_PATH=data/example.db |
| 31 | +# Collect data from GitHub |
| 32 | +$ npm start collect |
24 | 33 |
|
25 | 34 | # Push data to graphite |
26 | | -$ npm start | nc localhost 2003 |
| 35 | +$ npm start export | nc localhost 2003 |
27 | 36 |
|
28 | 37 | # The generated time series will be written to `stdout`. |
29 | 38 | # github.github-user-name.repository-name.pull_requests.time_to_merge 3450 1554125772 |
30 | 39 | # github.github-user-name.repository-name.pull_requests.time_to_merge 935617 1553187544 |
31 | 40 | # ... |
32 | 41 | ``` |
33 | 42 |
|
34 | | -## Todo |
| 43 | +You can run the complete stack using [Docker Compose](https://docs.docker.com/compose/), just set your environment variables in the `.env` file in the root project according to the example `.env.example` and run `docker-compose up`. |
35 | 44 |
|
36 | | -- [x] Exclude non-business hours from calculation |
37 | | -- [ ] Exclude public holidays from calculation |
| 45 | +For example: |
| 46 | +```sh |
| 47 | +# Note that the `./data` directory is mounted to the docker container, to keep your data persistent place your sqlite database in here |
| 48 | +$ cat > .env <<EOL |
| 49 | +GITHUB_USER_NAME=facebook |
| 50 | +GITHUB_REPO_NAME=react |
| 51 | +GITHUB_TOKEN=create a new token here https://github.com/settings/tokens/new |
| 52 | +DATABASE_PATH=path to your sqlite3 database e.g. data/github.db |
| 53 | +EOL |
| 54 | + |
| 55 | +$ docker-compose up |
| 56 | +``` |
0 commit comments