Skip to content

Commit

Permalink
Add Initial Prom Metrics For Load Balancer Count (#166)
Browse files Browse the repository at this point in the history
* Add inital prom metrics for lb count

Signed-off-by: Dejon Gill <[email protected]>

* Sepearate create/delete counts

Signed-off-by: Dejon Gill <[email protected]>

* lbdata can be nil here use the id from the event (#168)

Signed-off-by: Matt Siwiec <[email protected]>

* metadata status integration (#167)

Signed-off-by: Matt Siwiec <[email protected]>

* Add guard on create deployment if lb location is in operator watched locations (#170)

* √√ on create deployment if lb location is in operator watched locations

Signed-off-by: Matt Siwiec <[email protected]>

* changes test needs location

Signed-off-by: Matt Siwiec <[email protected]>

---------

Signed-off-by: Matt Siwiec <[email protected]>

* Publish Metering Event on Metadata Status Update (#172)

* publish metering event

Signed-off-by: Stephen Hwang <[email protected]>

* use changeset instead of eventtype

Signed-off-by: Stephen Hwang <[email protected]>

* use EventMessage

Signed-off-by: Stephen Hwang <[email protected]>

* remove extraneous config, add warn

Signed-off-by: Stephen Hwang <[email protected]>

* bump go

Signed-off-by: Stephen Hwang <[email protected]>

* Update Dockerfile

Signed-off-by: sthwang-metal <[email protected]>

* Update Dockerfile

Signed-off-by: sthwang-metal <[email protected]>

* Update Dockerfile

Signed-off-by: sthwang-metal <[email protected]>

---------

Signed-off-by: Stephen Hwang <[email protected]>
Signed-off-by: sthwang-metal <[email protected]>

* Allow trailing comments in blocks for TODOs

Signed-off-by: Dejon Gill <[email protected]>

* linter

Signed-off-by: Dejon Gill <[email protected]>

---------

Signed-off-by: Dejon Gill <[email protected]>
Signed-off-by: Matt Siwiec <[email protected]>
Signed-off-by: Stephen Hwang <[email protected]>
Signed-off-by: sthwang-metal <[email protected]>
Co-authored-by: Matt Siwiec <[email protected]>
Co-authored-by: sthwang-metal <[email protected]>
  • Loading branch information
3 people authored Feb 8, 2024
1 parent 25480b0 commit 7019ed9
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
linters-settings:
goimports:
local-prefixes: go.infratographer.com/load-balancer-operator
wsl:
allow-trailing-comment: true

linters:
enable:
Expand Down
1 change: 1 addition & 0 deletions internal/srv/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ func (suite *srvTestSuite) TestAttachRoleBinding() {
t.Fatal(err)
}
}

err = attachRoleBinding(srv.Context, cli, tcase.namespace)

if tcase.expectErr {
Expand Down
4 changes: 4 additions & 0 deletions internal/srv/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func (s *Server) processLoadBalancerChangeCreate(ctx context.Context, lb *loadBa
return err
}

numberLoadBalancersCreatedGauge.Inc()

return nil
}

Expand All @@ -25,6 +27,8 @@ func (s *Server) processLoadBalancerChangeDelete(ctx context.Context, lb *loadBa
return err
}

numberLoadBalancersDeletedGauge.Inc()

return nil
}

Expand Down
2 changes: 0 additions & 2 deletions internal/srv/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func (suite *srvTestSuite) TestProcessLoadBalancerChangeCreate() { //nolint:gove
} else {
assert.Nil(suite.T(), err)
}

// TODO: check if the namespace was created
// TODO: check if the helm release exists
})
Expand Down Expand Up @@ -197,7 +196,6 @@ func (suite *srvTestSuite) TestProcessLoadBalancerDelete() { //nolint:govet
assert.Error(suite.T(), err)
} else {
assert.Nil(suite.T(), err)

// TODO: check if the release is missing
// TODO: check if the namespace is missing
}
Expand Down
2 changes: 2 additions & 0 deletions internal/srv/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ func prepareLoadBalancer[M Message](ctx context.Context, msg M, s *Server) (*loa
err = errLoadBalancerInit
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())

return nil, err
}

span.SetAttributes(attribute.Bool("lbdata-lookup", true))
}

Expand Down
25 changes: 25 additions & 0 deletions internal/srv/prom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package srv

import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

const subsystem = "load_balancer_operator"

var (
numberLoadBalancersCreatedGauge = promauto.NewGauge(
prometheus.GaugeOpts{
Subsystem: subsystem,
Name: "load_balancers_created",
Help: "Total count of load balancers created",
},
)
numberLoadBalancersDeletedGauge = promauto.NewGauge(
prometheus.GaugeOpts{
Subsystem: subsystem,
Name: "load_balancers_deleted",
Help: "Total count of load balancers deleted",
},
)
)

0 comments on commit 7019ed9

Please sign in to comment.