Skip to content

Commit db4dd22

Browse files
committed
Add example database and make target to run demo
1 parent 7f072d0 commit db4dd22

File tree

5 files changed

+51
-26
lines changed

5 files changed

+51
-26
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,6 @@ typings/
225225
# End of https://www.gitignore.io/api/node,intellij,webstorm
226226

227227
*.db
228+
!data/example.db
228229

229-
dist
230+
dist

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.PHONY: default
2+
default: help;
3+
4+
CARBON_PLAINTEXT_PORT :=2003
5+
STACK_SLUG := 'github-pr-metrics-graphite-exporter'
6+
7+
help: ## Show this help
8+
@echo '----------------------------------------------------------------------'
9+
@echo $(STACK_SLUG)
10+
@echo '----------------------------------------------------------------------'
11+
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
12+
@echo '----------------------------------------------------------------------'
13+
14+
test: ## Execute tests
15+
@npm test
16+
17+
run: ## Builds and runs the graphite stack with some sample data
18+
@docker run -d \
19+
--name $(STACK_SLUG)\
20+
--restart=always\
21+
-p 80:80\
22+
-p $(CARBON_PLAINTEXT_PORT)-2004:$(CARBON_PLAINTEXT_PORT)-2004\
23+
-p 2023-2024:2023-2024\
24+
-p 8125:8125/udp\
25+
-p 8126:8126\
26+
graphiteapp/graphite-statsd
27+
@npm install
28+
@PULL_REQUESTS_DATABASE_PATH=data/example.db npm start | nc localhost $(CARBON_PLAINTEXT_PORT)
29+
@open 'http://localhost/?target=prs.time_to_merge&from=00%3A00_20190101&until=23%3A59_20190416'
30+
31+
stop: ## Stop the graphite stack
32+
@docker stop github-pr-metrics-graphite-exporter

README.md

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
1-
# Github PR metrics graphite exporter
1+
# Github PR Metrics Graphite Exporter
22

3-
### Description
4-
Converts raw github PR data to time series.
5-
6-
The data point is the number of seconds elapsed between the creation of the PR and the merging of the PR.
3+
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.
74

85
The timestamp is the creation time of the PR.
96

10-
Metrics name: `prs.time_to_merge`
7+
Exposed metrics name: `prs.time_to_merge`
118

12-
### Example output:
9+
## Usage
1310

14-
```
15-
prs.time_to_merge 3450 1554125772
16-
prs.time_to_merge 935617 1553187544
17-
```
11+
```sh
12+
$ npm install
1813

19-
### Requirements
20-
Node v10+
14+
# Path to the SQLite db file containing the PR data retrieved from GitHub.
15+
$ export PULL_REQUESTS_DATABASE_PATH=data/example.db
2116

22-
### Installation
23-
`npm install`
17+
$ npm start
2418

25-
### Required environment variables
26-
`PULL_REQUESTS_DATABASE_PATH`: path to the SQLite db file containing the PR data retrieved from GitHub.
27-
28-
###Usage
29-
```
30-
PULL_REQUESTS_DATABASE_PATH=sample.db node ./node_modules/ts-node/dist/bin.js src/index.ts
19+
# The generated time series will be written to `stdout`.
20+
# prs.time_to_merge 3450 1554125772
21+
# prs.time_to_merge 935617 1553187544
22+
# ...
3123
```
3224

33-
The generated time series will be written to `stdout`.
25+
If you have docker installed, try `make run` to explore the metric, the target which spins up a Graphite stack and injects some [sample data](./data/example.db). The Graphite UI is being exposed on [localhost:80](http://localhost).

data/example.db

44 KB
Binary file not shown.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"description": "",
55
"main": "index.ts",
66
"scripts": {
7-
"start": "ts-node src/index.ts",
8-
"test": "jest",
9-
"tsc": "tsc"
7+
"dist": "tsc",
8+
"start": "node ./node_modules/.bin/ts-node src/index.ts",
9+
"test": "node ./node_modules/.bin/jest"
1010
},
1111
"author": "Csongor Zalatnai",
1212
"license": "ISC",

0 commit comments

Comments
 (0)