Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate open and closed issue in metrics #16637

Merged
merged 3 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions models/models.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ type Statistic struct {
Counter struct {
User, Org, PublicKey,
Repo, Watch, Star, Action, Access,
Issue, Comment, Oauth, Follow,
IssueClosed, IssueOpen, Comment, Oauth, Follow,
zeripath marked this conversation as resolved.
Show resolved Hide resolved
Mirror, Release, LoginSource, Webhook,
Milestone, Label, HookTask,
Team, UpdateTask, Attachment int64
Expand All @@ -289,7 +289,8 @@ func GetStatistic() (stats Statistic) {
stats.Counter.Star, _ = x.Count(new(Star))
stats.Counter.Action, _ = x.Count(new(Action))
stats.Counter.Access, _ = x.Count(new(Access))
stats.Counter.Issue, _ = x.Count(new(Issue))
stats.Counter.IssueClosed, _ = x.Where("is_closed=?", true).Count(new(Issue))
zeripath marked this conversation as resolved.
Show resolved Hide resolved
stats.Counter.IssueOpen, _ = x.Where("is_closed=?", false).Count(new(Issue))
stats.Counter.Comment, _ = x.Count(new(Comment))
stats.Counter.Oauth = 0
stats.Counter.Follow, _ = x.Count(new(Follow))
Expand Down
26 changes: 19 additions & 7 deletions modules/metrics/collector.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type Collector struct {
Comments *prometheus.Desc
Follows *prometheus.Desc
HookTasks *prometheus.Desc
Issues *prometheus.Desc
IssuesOpen *prometheus.Desc
zeripath marked this conversation as resolved.
Show resolved Hide resolved
IssuesClosed *prometheus.Desc
Labels *prometheus.Desc
LoginSources *prometheus.Desc
Milestones *prometheus.Desc
Expand Down Expand Up @@ -72,9 +73,14 @@ func NewCollector() Collector {
"Number of HookTasks",
nil, nil,
),
Issues: prometheus.NewDesc(
namespace+"issues",
"Number of Issues",
IssuesOpen: prometheus.NewDesc(
zeripath marked this conversation as resolved.
Show resolved Hide resolved
namespace+"issues_open",
"Number of open Issues",
nil, nil,
),
IssuesClosed: prometheus.NewDesc(
namespace+"issues_closed",
"Number of closed Issues",
nil, nil,
),
Labels: prometheus.NewDesc(
Expand Down Expand Up @@ -164,7 +170,8 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.Comments
ch <- c.Follows
ch <- c.HookTasks
ch <- c.Issues
ch <- c.IssuesOpen
zeripath marked this conversation as resolved.
Show resolved Hide resolved
ch <- c.IssuesClosed
ch <- c.Labels
ch <- c.LoginSources
ch <- c.Milestones
Expand Down Expand Up @@ -217,9 +224,14 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
float64(stats.Counter.HookTask),
)
ch <- prometheus.MustNewConstMetric(
c.Issues,
c.IssuesClosed,
zeripath marked this conversation as resolved.
Show resolved Hide resolved
prometheus.GaugeValue,
float64(stats.Counter.IssueClosed),
)
ch <- prometheus.MustNewConstMetric(
c.IssuesOpen,
prometheus.GaugeValue,
float64(stats.Counter.Issue),
float64(stats.Counter.IssueOpen),
)
ch <- prometheus.MustNewConstMetric(
c.Labels,
Expand Down