Skip to content

Commit

Permalink
Replace gostats with tally (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
nishkrishnan authored Jan 13, 2022
1 parent c23b9cc commit 5cf9ccf
Show file tree
Hide file tree
Showing 27 changed files with 620 additions and 338 deletions.
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/kelseyhightower/envconfig v1.4.1-0.20200624135755-c974cae29cf5 // indirect
github.com/klauspost/compress v1.11.2 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 // indirect
github.com/lyft/gostats v0.4.5
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
Expand Down Expand Up @@ -101,7 +99,7 @@ require (
github.com/zclconf/go-cty v1.5.1 // indirect
go.etcd.io/bbolt v1.3.6
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.0
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
Expand Down Expand Up @@ -130,5 +128,10 @@ require (
require (
github.com/antlr/antlr4 v0.0.0-20201206235148-c87e55b61113 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cactus/go-statsd-client/statsd v0.0.0-20200623234511-94959e3146b2
github.com/nikunjy/rules v0.0.0-20200120082459-0b7c4dc9dc86 // indirect
github.com/twmb/murmur3 v1.1.6 // indirect
github.com/uber-go/tally v3.4.3+incompatible
)

require github.com/onsi/ginkgo v1.14.0 // indirect
18 changes: 8 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ github.com/bradleyfalzon/ghinstallation v1.1.1 h1:pmBXkxgM1WeF8QYvDLT5kuQiHMcmf+
github.com/bradleyfalzon/ghinstallation v1.1.1/go.mod h1:vyCmHTciHx/uuyN82Zc3rXN3X2KTK8nUTCrTMwAhcug=
github.com/briandowns/spinner v0.0.0-20170614154858-48dbb65d7bd5 h1:osZyZB7J4kE1tKLeaUjV6+uZVBfS835T0I/RxmwWw1w=
github.com/briandowns/spinner v0.0.0-20170614154858-48dbb65d7bd5/go.mod h1:hw/JEQBIE+c/BLI4aKM8UU8v+ZqrD3h7HC27kKt8JQU=
github.com/cactus/go-statsd-client/statsd v0.0.0-20200623234511-94959e3146b2 h1:GgJnJEJYymy/lx+1zXOO2TvGPRQJJ9vz4onxnA9gF3k=
github.com/cactus/go-statsd-client/statsd v0.0.0-20200623234511-94959e3146b2/go.mod h1:l/bIBLeOl9eX+wxJAzxS4TveKRtAqlyDpHjhkfO0MEI=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
Expand Down Expand Up @@ -274,9 +276,6 @@ github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfE
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/kelseyhightower/envconfig v1.4.1-0.20200624135755-c974cae29cf5 h1:TW7YQVw105jR4B+n/tAlkKNbYFSdWRK1RyLL5YYruso=
github.com/kelseyhightower/envconfig v1.4.1-0.20200624135755-c974cae29cf5/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ=
Expand All @@ -294,8 +293,6 @@ github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 h1:MNApn+Z+fIT4NPZopPfCc1obT6aY3SVM6DOctz1A9ZU=
github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg=
github.com/lyft/gostats v0.4.5 h1:2KYdjsz+RfxeJAWqOpYUlyXgFgYd0SxPFUSFm9PdXM4=
github.com/lyft/gostats v0.4.5/go.mod h1:7ECvCenOq0N9BE6Tn+dtwFoS6xAwbvsx4tVSETO/hmc=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
Expand Down Expand Up @@ -380,7 +377,6 @@ github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f h1:tygelZueB1EtXk
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.6.1-0.20200528085638-6699a89a232f h1:qqqIhBDFUBrbMezIyJkKWIpf+E5CdObleGMjW1s19Hg=
github.com/sirupsen/logrus v1.6.1-0.20200528085638-6699a89a232f/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
Expand Down Expand Up @@ -413,6 +409,10 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/thomaspoignant/go-feature-flag v0.18.4 h1:LJ5dns5HRMzXATggfXKHanrGriN0DfQ5cm2N7U9g/0A=
github.com/thomaspoignant/go-feature-flag v0.18.4/go.mod h1:S/z9nx718SSumYgGL0LK71QRl3lQvFLAaQlPzexgMus=
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
github.com/uber-go/tally v3.4.3+incompatible h1:Oq25FXV8cWHPRo+EPeNdbN3LfuozC9mDK2/4vZ1k38U=
github.com/uber-go/tally v3.4.3+incompatible/go.mod h1:YDTIBxdXyOU/sCWilKB4bgyufu1cEi0jdVnRdxvjnmU=
github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ=
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
Expand Down Expand Up @@ -444,8 +444,9 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
Expand All @@ -460,7 +461,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200403201458-baeed622b8d8/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
Expand Down Expand Up @@ -775,14 +775,12 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M=
Expand Down
14 changes: 7 additions & 7 deletions server/controllers/events/events_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"strings"

"github.com/google/go-github/v31/github"
stats "github.com/lyft/gostats"
"github.com/mcdafydd/go-azuredevops/azuredevops"
"github.com/microcosm-cc/bluemonday"
"github.com/pkg/errors"
Expand All @@ -30,6 +29,7 @@ import (
"github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud"
"github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver"
"github.com/runatlantis/atlantis/server/logging"
"github.com/uber-go/tally"
gitlab "github.com/xanzy/go-gitlab"
)

Expand All @@ -49,7 +49,7 @@ type VCSEventsController struct {
CommandRunner events.CommandRunner
PullCleaner events.PullCleaner
Logger logging.SimpleLogging
Scope stats.Scope
Scope tally.Scope
Parser events.EventParsing
CommentParser events.CommentParsing
ApplyDisabled bool
Expand Down Expand Up @@ -158,7 +158,7 @@ func (e *VCSEventsController) handleGithubPost(w http.ResponseWriter, r *http.Re

githubReqID := "X-Github-Delivery=" + r.Header.Get("X-Github-Delivery")
logger := e.Logger.With("gh-request-id", githubReqID)
scope := e.Scope.Scope("github.event")
scope := e.Scope.SubScope("github.event")

logger.Debug("request valid")

Expand All @@ -169,10 +169,10 @@ func (e *VCSEventsController) handleGithubPost(w http.ResponseWriter, r *http.Re
switch event := event.(type) {
case *github.IssueCommentEvent:
resp = e.HandleGithubCommentEvent(event, githubReqID, logger)
scope = scope.Scope(fmt.Sprintf("comment.%s", *event.Action))
scope = scope.SubScope(fmt.Sprintf("comment.%s", *event.Action))
case *github.PullRequestEvent:
resp = e.HandleGithubPullRequestEvent(logger, event, githubReqID)
scope = scope.Scope(fmt.Sprintf("pr.%s", *event.Action))
scope = scope.SubScope(fmt.Sprintf("pr.%s", *event.Action))
default:
resp = HttpResponse{
body: fmt.Sprintf("Ignoring unsupported event %s", githubReqID),
Expand All @@ -181,13 +181,13 @@ func (e *VCSEventsController) handleGithubPost(w http.ResponseWriter, r *http.Re

if resp.err.code != 0 {
logger.Err("error handling gh post code: %d err: %s", resp.err.code, resp.err.err.Error())
scope.NewCounter(fmt.Sprintf("error_%d", resp.err.code)).Inc()
scope.Counter(fmt.Sprintf("error_%d", resp.err.code)).Inc(1)
w.WriteHeader(resp.err.code)
fmt.Fprintln(w, resp.err.err.Error())
return
}

scope.NewCounter(fmt.Sprintf("success_%d", http.StatusOK)).Inc()
scope.Counter(fmt.Sprintf("success_%d", http.StatusOK)).Inc(1)
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, resp.body)
}
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/google/go-github/v31/github"
"github.com/hashicorp/go-getter"
"github.com/hashicorp/go-version"
stats "github.com/lyft/gostats"
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server"
events_controllers "github.com/runatlantis/atlantis/server/controllers/events"
Expand All @@ -40,6 +39,7 @@ import (
handlermocks "github.com/runatlantis/atlantis/server/handlers/mocks"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/lyft/feature"
"github.com/runatlantis/atlantis/server/metrics"
. "github.com/runatlantis/atlantis/testing"
)

Expand Down Expand Up @@ -895,7 +895,7 @@ func setupE2E(t *testing.T, repoDir string) (events_controllers.VCSEventsControl
WorkingDir: workingDir,
PreWorkflowHookRunner: mockPreWorkflowHookRunner,
}
statsScope := stats.NewStore(stats.NewNullSink(), false)
statsScope, _, err := metrics.NewLoggingScope(logger, "atlantis")

projectCommandBuilder := events.NewProjectCommandBuilder(
userConfig.EnablePolicyChecksFlag,
Expand Down
44 changes: 29 additions & 15 deletions server/controllers/events/events_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"testing"

"github.com/google/go-github/v31/github"
stats "github.com/lyft/gostats"
. "github.com/petergtz/pegomock"
events_controllers "github.com/runatlantis/atlantis/server/controllers/events"
"github.com/runatlantis/atlantis/server/controllers/events/mocks"
Expand All @@ -36,6 +35,7 @@ import (
"github.com/runatlantis/atlantis/server/events/models"
vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/metrics"
. "github.com/runatlantis/atlantis/testing"
gitlab "github.com/xanzy/go-gitlab"
)
Expand Down Expand Up @@ -199,9 +199,11 @@ func TestPost_GitlabCommentNotAllowlisted(t *testing.T) {
t.Log("when the event is a gitlab comment from a repo that isn't allowlisted we comment with an error")
RegisterMockTestingT(t)
vcsClient := vcsmocks.NewMockClient()
logger := logging.NewNoopLogger(t)
scope, _, _ := metrics.NewLoggingScope(logger, "null")
e := events_controllers.VCSEventsController{
Logger: logging.NewNoopLogger(t),
Scope: stats.NewStore(stats.NewNullSink(), false).Scope("null"),
Logger: logger,
Scope: scope,
CommentParser: &events.CommentParser{},
GitlabRequestParserValidator: &events_controllers.DefaultGitlabRequestParserValidator{},
Parser: &events.EventParser{},
Expand All @@ -228,9 +230,11 @@ func TestPost_GitlabCommentNotAllowlistedWithSilenceErrors(t *testing.T) {
t.Log("when the event is a gitlab comment from a repo that isn't allowlisted and we are silencing errors, do not comment with an error")
RegisterMockTestingT(t)
vcsClient := vcsmocks.NewMockClient()
logger := logging.NewNoopLogger(t)
scope, _, _ := metrics.NewLoggingScope(logger, "null")
e := events_controllers.VCSEventsController{
Logger: logging.NewNoopLogger(t),
Scope: stats.NewStore(stats.NewNullSink(), false).Scope("null"),
Logger: logger,
Scope: scope,
CommentParser: &events.CommentParser{},
GitlabRequestParserValidator: &events_controllers.DefaultGitlabRequestParserValidator{},
Parser: &events.EventParser{},
Expand Down Expand Up @@ -258,9 +262,11 @@ func TestPost_GithubCommentNotAllowlisted(t *testing.T) {
t.Log("when the event is a github comment from a repo that isn't allowlisted we comment with an error")
RegisterMockTestingT(t)
vcsClient := vcsmocks.NewMockClient()
logger := logging.NewNoopLogger(t)
scope, _, _ := metrics.NewLoggingScope(logger, "null")
e := events_controllers.VCSEventsController{
Logger: logging.NewNoopLogger(t),
Scope: stats.NewStore(stats.NewNullSink(), false).Scope("null"),
Logger: logger,
Scope: scope,
GithubRequestValidator: &events_controllers.DefaultGithubRequestValidator{},
CommentParser: &events.CommentParser{},
Parser: &events.EventParser{},
Expand Down Expand Up @@ -288,9 +294,11 @@ func TestPost_GithubCommentNotAllowlistedWithSilenceErrors(t *testing.T) {
t.Log("when the event is a github comment from a repo that isn't allowlisted and we are silencing errors, do not comment with an error")
RegisterMockTestingT(t)
vcsClient := vcsmocks.NewMockClient()
logger := logging.NewNoopLogger(t)
scope, _, _ := metrics.NewLoggingScope(logger, "null")
e := events_controllers.VCSEventsController{
Logger: logging.NewNoopLogger(t),
Scope: stats.NewStore(stats.NewNullSink(), false).Scope("null"),
Logger: logger,
Scope: scope,
GithubRequestValidator: &events_controllers.DefaultGithubRequestValidator{},
CommentParser: &events.CommentParser{},
Parser: &events.EventParser{},
Expand Down Expand Up @@ -486,10 +494,12 @@ func TestPost_AzureDevopsPullRequestIgnoreEvent(t *testing.T) {
vcsmock := vcsmocks.NewMockClient()
repoAllowlistChecker, err := events.NewRepoAllowlistChecker("*")
Ok(t, err)
logger := logging.NewNoopLogger(t)
scope, _, _ := metrics.NewLoggingScope(logger, "null")
e := events_controllers.VCSEventsController{
TestingMode: true,
Logger: logging.NewNoopLogger(t),
Scope: stats.NewStore(stats.NewNullSink(), false).Scope("null"),
Logger: logger,
Scope: scope,
ApplyDisabled: false,
AzureDevopsWebhookBasicUser: user,
AzureDevopsWebhookBasicPassword: secret,
Expand Down Expand Up @@ -643,6 +653,8 @@ func TestPost_BBServerPullClosed(t *testing.T) {
pullCleaner := emocks.NewMockPullCleaner()
allowlist, err := events.NewRepoAllowlistChecker("*")
Ok(t, err)
logger := logging.NewNoopLogger(t)
scope, _, _ := metrics.NewLoggingScope(logger, "null")
ec := &events_controllers.VCSEventsController{
PullCleaner: pullCleaner,
Parser: &events.EventParser{
Expand All @@ -653,8 +665,8 @@ func TestPost_BBServerPullClosed(t *testing.T) {
RepoAllowlistChecker: allowlist,
SupportedVCSHosts: []models.VCSHostType{models.BitbucketServer},
VCSClient: nil,
Logger: logging.NewNoopLogger(t),
Scope: stats.NewStore(stats.NewNullSink(), false).Scope("null"),
Logger: logger,
Scope: scope,
}

// Build HTTP request.
Expand Down Expand Up @@ -772,10 +784,12 @@ func setup(t *testing.T) (events_controllers.VCSEventsController, *mocks.MockGit
vcsmock := vcsmocks.NewMockClient()
repoAllowlistChecker, err := events.NewRepoAllowlistChecker("*")
Ok(t, err)
logger := logging.NewNoopLogger(t)
scope, _, _ := metrics.NewLoggingScope(logger, "null")
e := events_controllers.VCSEventsController{
TestingMode: true,
Logger: logging.NewNoopLogger(t),
Scope: stats.NewStore(stats.NewNullSink(), false).Scope("null"),
Logger: logger,
Scope: scope,
GithubRequestValidator: v,
Parser: p,
CommentParser: cp,
Expand Down
Loading

0 comments on commit 5cf9ccf

Please sign in to comment.