这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ github_repo_forks{archived="false",fork="false",language="Go",license="mit",priv
github_repo_open_issues{archived="false",fork="false",language="Go",license="mit",private="false",repo="github-exporter",user="githubexporter"} 28
# HELP github_repo_pull_request_count Total number of pull requests for given repository
# TYPE github_repo_pull_request_count gauge
github_repo_pull_request_count{repo="github-exporter",user="githubexporter"} 7
github_repo_pull_request_count{archived="false",fork="false",language="Go",license="mit",private="false",repo="github-exporter",user="githubexporter"} 7
# HELP github_repo_size_kb Size in KB for given repository
# TYPE github_repo_size_kb gauge
github_repo_size_kb{archived="false",fork="false",language="Go",license="mit",private="false",repo="github-exporter",user="githubexporter"} 2185
Expand Down
4 changes: 2 additions & 2 deletions exporter/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func AddMetrics(cfg *config.Config) map[string]*prometheus.Desc {
APIMetrics["PullRequestCount"] = prometheus.NewDesc(
prometheus.BuildFQName("github", "repo", "pull_request_count"),
"Total number of pull requests for given repository",
[]string{"repo", "user"}, nil,
[]string{"repo", "user", "private", "fork", "archived", "license", "language"}, nil,
)
APIMetrics["Watchers"] = prometheus.NewDesc(
prometheus.BuildFQName("github", "repo", "watchers"),
Expand Down Expand Up @@ -115,7 +115,7 @@ func (e *Exporter) processMetrics(data []*Datum, rates *[]RateLimit, ch chan<- p
ch <- prometheus.MustNewConstMetric(e.APIMetrics["OpenIssues"], prometheus.GaugeValue, float64(x.OpenIssues-prCount), x.Name, x.Owner.Login, strconv.FormatBool(x.Private), strconv.FormatBool(x.Fork), strconv.FormatBool(x.Archived), x.License.Key, x.Language)

// prCount
ch <- prometheus.MustNewConstMetric(e.APIMetrics["PullRequestCount"], prometheus.GaugeValue, float64(prCount), x.Name, x.Owner.Login)
ch <- prometheus.MustNewConstMetric(e.APIMetrics["PullRequestCount"], prometheus.GaugeValue, float64(prCount), x.Name, x.Owner.Login, strconv.FormatBool(x.Private), strconv.FormatBool(x.Fork), strconv.FormatBool(x.Archived), x.License.Key, x.Language)
}

// Set Rate limit stats
Expand Down
2 changes: 1 addition & 1 deletion test/github_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestGithubExporter(t *testing.T) {
Assert(bodyContains(`github_rate_reset{resource="integration_manifest"} 3e+09`)).
Assert(bodyContains(`github_rate_reset{resource="search"} 3e+09`)).
Assert(bodyContains(`github_repo_forks{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 10`)).
Assert(bodyContains(`github_repo_pull_request_count{repo="myRepo",user="myOrg"} 3`)).
Assert(bodyContains(`github_repo_pull_request_count{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 3`)).
Assert(bodyContains(`github_repo_open_issues{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 2`)).
Assert(bodyContains(`github_repo_size_kb{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 946`)).
Assert(bodyContains(`github_repo_stars{archived="false",fork="false",language="Go",license="mit",private="false",repo="myRepo",user="myOrg"} 120`)).
Expand Down