Skip to content
This repository has been archived by the owner on Oct 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #61 from rebuy-de/ignore-statsd-errors
Browse files Browse the repository at this point in the history
continue on statsd errors
  • Loading branch information
svenwltr authored Jul 5, 2017
2 parents 0e40c67 + 362e586 commit 2ff0966
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
6 changes: 1 addition & 5 deletions pkg/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ func New(p *Parameters) (*App, error) {
app.Parameters = p

app.Clients = &Clients{}
app.Clients.Statsd, err = statsdw.New(p.StatsdAddress)
if err != nil {
return nil, errors.Wrap(err, "failed to initialize statsd client")
}

app.Clients.Statsd = statsdw.New(p.StatsdAddress)
app.Clients.GitHub = gh.New(p.GitHubToken, p.HTTPCacheDir, app.Clients.Statsd)
app.Clients.Kubectl = kubectl.New(p.KubectlPath, p.Kubeconfig)

Expand Down
19 changes: 14 additions & 5 deletions pkg/statsdw/wrapper.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package statsdw

import statsd "gopkg.in/alexcesaro/statsd.v2"
import (
"fmt"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
statsd "gopkg.in/alexcesaro/statsd.v2"
)

var Prefix = "kubernetes-deployment"

type Wrapper struct {
c *statsd.Client
}

func New(addr string) (Interface, error) {
func New(addr string) Interface {
if addr == "" {
return NullClient{}, nil
return NullClient{}
}

c, err := statsd.New(
Expand All @@ -19,10 +25,13 @@ func New(addr string) (Interface, error) {
statsd.TagsFormat(statsd.Datadog),
)
if err != nil {
return nil, err
log.WithFields(log.Fields{
"StackTrace": fmt.Sprintf("%+v", errors.WithStack(err)),
}).Warn("failed to initialize statsd client")
return NullClient{}
}

return &Wrapper{c}, nil
return &Wrapper{c}
}

func (w *Wrapper) Gauge(bucket string, value interface{}) {
Expand Down

0 comments on commit 2ff0966

Please sign in to comment.