Skip to content

Commit 8979a32

Browse files
authored
chore(metrics): add repository counter on the principal (#639)
Signed-off-by: Chetan Banavikalmutt <[email protected]>
1 parent e90cc07 commit 8979a32

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

internal/metrics/metrics.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ type PrincipalMetrics struct {
5252
AppProjectUpdated prometheus.Counter
5353
AppProjectDeleted prometheus.Counter
5454

55+
RepositoryCreated prometheus.Counter
56+
RepositoryUpdated prometheus.Counter
57+
RepositoryDeleted prometheus.Counter
58+
5559
EventReceived prometheus.Counter
5660
EventSent prometheus.Counter
5761

@@ -95,28 +99,41 @@ func NewPrincipalMetrics() *PrincipalMetrics {
9599

96100
ApplicationCreated: promauto.NewCounter(prometheus.CounterOpts{
97101
Name: "principal_applications_created",
98-
Help: "The total number of applications created by agents",
102+
Help: "The total number of applications created on the control plane",
99103
}),
100104
ApplicationUpdated: promauto.NewCounter(prometheus.CounterOpts{
101105
Name: "principal_applications_updated",
102-
Help: "The total number of applications updated by agents",
106+
Help: "The total number of applications updated on the control plane",
103107
}),
104108
ApplicationDeleted: promauto.NewCounter(prometheus.CounterOpts{
105109
Name: "principal_applications_deleted",
106-
Help: "The total number of applications deleted by agents",
110+
Help: "The total number of applications deleted on the control plane",
107111
}),
108112

109113
AppProjectCreated: promauto.NewCounter(prometheus.CounterOpts{
110114
Name: "principal_app_projects_created",
111-
Help: "The total number of app project created by agents",
115+
Help: "The total number of app project created on the control plane",
112116
}),
113117
AppProjectUpdated: promauto.NewCounter(prometheus.CounterOpts{
114118
Name: "principal_app_projects_updated",
115-
Help: "The total number of app project updated by agents",
119+
Help: "The total number of app project updated on the control plane",
116120
}),
117121
AppProjectDeleted: promauto.NewCounter(prometheus.CounterOpts{
118122
Name: "principal_app_projects_deleted",
119-
Help: "The total number of app project deleted by agents",
123+
Help: "The total number of app project deleted on the control plane",
124+
}),
125+
126+
RepositoryCreated: promauto.NewCounter(prometheus.CounterOpts{
127+
Name: "principal_repositories_created",
128+
Help: "The total number of repositories created on the control plane",
129+
}),
130+
RepositoryUpdated: promauto.NewCounter(prometheus.CounterOpts{
131+
Name: "principal_repositories_updated",
132+
Help: "The total number of repositories updated on the control plane",
133+
}),
134+
RepositoryDeleted: promauto.NewCounter(prometheus.CounterOpts{
135+
Name: "principal_repositories_deleted",
136+
Help: "The total number of repositories deleted on the control plane",
120137
}),
121138

122139
EventReceived: promauto.NewCounter(prometheus.CounterOpts{

principal/callbacks.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ func (s *Server) newRepositoryCallback(outbound *corev1.Secret) {
377377
s.repoToAgents.Add(outbound.Name, agent)
378378
logCtx.Tracef("Added repository %s to send queue, total length now %d", outbound.Name, q.Len())
379379
}
380+
381+
if s.metrics != nil {
382+
s.metrics.RepositoryCreated.Inc()
383+
}
380384
}
381385

382386
func (s *Server) updateRepositoryCallback(old, new *corev1.Secret) {
@@ -389,6 +393,10 @@ func (s *Server) updateRepositoryCallback(old, new *corev1.Secret) {
389393
logCtx.Info("Update repository event")
390394

391395
s.syncRepositoryUpdatesToAgents(old, new, logCtx)
396+
397+
if s.metrics != nil {
398+
s.metrics.RepositoryUpdated.Inc()
399+
}
392400
}
393401

394402
func (s *Server) deleteRepositoryCallback(outbound *corev1.Secret) {
@@ -444,6 +452,10 @@ func (s *Server) deleteRepositoryCallback(outbound *corev1.Secret) {
444452
s.repoToAgents.Delete(outbound.Name, agent)
445453
logCtx.WithField("sendq_len", q.Len()+1).Tracef("Added repository delete event to send queue")
446454
}
455+
456+
if s.metrics != nil {
457+
s.metrics.RepositoryDeleted.Inc()
458+
}
447459
}
448460

449461
// deleteNamespaceCallback is called when the user deletes the agent namespace.

0 commit comments

Comments
 (0)