Skip to content

Commit

Permalink
Add metrics to receiver and event server
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Laine <[email protected]>
  • Loading branch information
Philip Laine committed Mar 31, 2021
1 parent 59234b1 commit fd9526d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 11 deletions.
11 changes: 10 additions & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/sethvargo/go-limiter/memorystore"
prommetrics "github.com/slok/go-http-metrics/metrics/prometheus"
"github.com/slok/go-http-metrics/middleware"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
Expand All @@ -53,6 +55,7 @@ import (
var cfg *rest.Config
var k8sClient client.Client
var testEnv *envtest.Environment
var eventMdlw middleware.Middleware

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)
Expand All @@ -72,6 +75,12 @@ var _ = BeforeSuite(func(done Done) {
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
}

eventMdlw = middleware.New(middleware.Config{
Recorder: prommetrics.NewRecorder(prommetrics.Config{
Prefix: "event",
}),
})

var err error
cfg, err = testEnv.Start()
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -136,7 +145,7 @@ var _ = Describe("Event handlers", func() {
// TODO let OS assign port number
eventServer := server.NewEventServer("127.0.0.1:56789", logf.Log, k8sClient)
stopCh = make(chan struct{})
go eventServer.ListenAndServe(stopCh, store)
go eventServer.ListenAndServe(stopCh, eventMdlw, store)
})

AfterEach(func() {
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ require (
github.com/getsentry/sentry-go v0.10.0
github.com/go-logr/logr v0.3.0
github.com/google/go-github/v32 v32.1.0
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-retryablehttp v0.6.8
github.com/ktrysmt/go-bitbucket v0.6.5
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5
github.com/onsi/ginkgo v1.14.1
github.com/onsi/gomega v1.10.2
github.com/prometheus/client_golang v1.7.1
github.com/sethvargo/go-limiter v0.6.0
github.com/slok/go-http-metrics v0.9.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.6.1
github.com/whilp/git-urls v1.0.0
Expand Down
Loading

0 comments on commit fd9526d

Please sign in to comment.