Skip to content

Commit

Permalink
auth: default statsdclient
Browse files Browse the repository at this point in the history
  • Loading branch information
jphines committed May 22, 2019
1 parent 58890b3 commit a860298
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion cmd/sso-auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func main() {
os.Exit(1)
}

statsdClient, err := auth.NewStatsdClient(opts.StatsdHost, opts.StatsdPort)
if err != nil {
logger.Error(err, "error creating statsd client")
os.Exit(1)
}

authMux, err := auth.NewAuthenticatorMux(opts)
if err != nil {
logger.Error(err, "error creating new AuthenticatorMux")
Expand All @@ -44,7 +50,7 @@ func main() {
Addr: fmt.Sprintf(":%d", opts.Port),
ReadTimeout: opts.TCPReadTimeout,
WriteTimeout: opts.TCPWriteTimeout,
Handler: auth.NewLoggingHandler(os.Stdout, timeoutHandler, opts.RequestLogging, authenticator.StatsdClient),
Handler: auth.NewLoggingHandler(os.Stdout, timeoutHandler, opts.RequestLogging, statsdClient),
}

logger.Fatal(s.ListenAndServe())
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/datadog/datadog-go/statsd"
)

func newStatsdClient(host string, port int) (*statsd.Client, error) {
func NewStatsdClient(host string, port int) (*statsd.Client, error) {
client, err := statsd.New(net.JoinHostPort(host, strconv.Itoa(port)))
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions internal/auth/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func newTestStatsdClient(t *testing.T) (*statsd.Client, string, int) {

client, err := newStatsdClient("127.0.0.1", 8125)
client, err := NewStatsdClient("127.0.0.1", 8125)
if err != nil {
t.Fatalf("error starting new statsd client %s", err.Error())
}
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestNewStatsd(t *testing.T) {
t.Fatalf("error while instantiating config options: %s", err.Error())
}
opts.Validate()
client, err := newStatsdClient(tc.host, tc.port)
client, err := NewStatsdClient(tc.host, tc.port)
if err != nil {
t.Fatalf("error starting new statsd client: %s", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func AssignStatsdClient(opts *Options) func(*Authenticator) error {
return func(proxy *Authenticator) error {
logger := log.NewLogEntry()

StatsdClient, err := newStatsdClient(opts.StatsdHost, opts.StatsdPort)
StatsdClient, err := NewStatsdClient(opts.StatsdHost, opts.StatsdPort)
if err != nil {
return fmt.Errorf("error setting up statsd client error=%s", err)
}
Expand Down

0 comments on commit a860298

Please sign in to comment.