github-exporter icon indicating copy to clipboard operation
github-exporter copied to clipboard

Refactored github-exporter

Open dgeorgievski opened this issue 4 years ago • 4 comments

I've been evaluating github-exporter at wiley.com as part of our strategy to adopt Prometheus and Cortex as scalable enterprise services for monitoring in the cloud.

We are interested to use github-exporter and love to contribute to this project, but considering the scope of this PR I wanted to follow up first with a personal PR.

Changes

OpenIssues In the current form OpenIssues counts the non-PR issues, https://github.com/infinityworks/github-exporter/blob/master/exporter/metrics.go#L80-L83

According to GitHub definition OpenIssues is a sum of PRs + non-PR issues. https://docs.github.com/en/rest/reference/issues

Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. For this reason, "Issues" endpoints may return both issues and pull requests in the response.

Querying PRs

  • Incorrect paging In the current form only page 0 is collected which contributes to incorrect PR reporting as soon as the repo has more PRs than the default page size returned by GH. I believe the default is 30. https://github.com/infinityworks/github-exporter/blob/master/exporter/gather.go#L121

Additions

Querying PRs

  • Added new options for querying GitHub pulls Added PR_QUERY_OPTIONS to be able to control PRs query parameters. Example: per_page=100&sort=long-running&direction=descending

See for more details https://docs.github.com/en/rest/reference/pulls#list-pull-requests

  • Added a new metric for long running PR requests - PullRequestLongRunningCount By default PRs are considered long running if not closed after two weeks. The threshold is controlled by PR_LONG_RUNNING_TIME_DIFF env variable. This metric is important for Wiley to track PRs that are open for long periods. With this we plan to provide feedback to owners of monitored repos so they can close outstanding PRs.

Helm chart The chart helps with managing github-exporter deployments in Kubernetes. Integration with Prrometheus is achieved through the k8s ServiceMonitor.

dgeorgievski avatar Mar 23 '21 21:03 dgeorgievski

Thanks @dgeorgievski. Let me have a review but from an initial scan, this looks fantastic!

Rucknar avatar Mar 23 '21 21:03 Rucknar

Of note, there is a 'WIP' though it's a bit stale now, refactored to address some of the open issues:

https://github.com/infinityworks/github-exporter/pull/54

Rucknar avatar Mar 23 '21 21:03 Rucknar

Of note, there is a 'WIP' though it's a bit stale now, refactored to address some of the open issues:

#54

Thanks for sharing @Rucknar . We'd love to help with the WIPs tasks. Many of them overlap with our roadmap especially when we start ingesting more metrics from our ever growing GitHub footprint.

dgeorgievski avatar Mar 24 '21 17:03 dgeorgievski

Hi @Rucknar ,

Any update on the nest steps?

dgeorgievski avatar Apr 09 '21 15:04 dgeorgievski