Skip to content

Commit

Permalink
Use analytics package from gocommon instead of librato directly
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed May 26, 2022
1 parent d10c3f2 commit f337d32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"
"time"

"github.com/nyaruka/librato"
"github.com/nyaruka/gocommon/analytics"
"github.com/nyaruka/rp-indexer/indexers"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -38,10 +38,11 @@ func NewDaemon(cfg *Config, db *sql.DB, ixs []indexers.Indexer, poll time.Durati
func (d *Daemon) Start() {
// if we have a librato token, configure it
if d.cfg.LibratoToken != "" {
librato.Configure(d.cfg.LibratoUsername, d.cfg.LibratoToken, d.cfg.InstanceName, time.Second, d.wg)
librato.Start()
analytics.RegisterBackend(analytics.NewLibrato(d.cfg.LibratoUsername, d.cfg.LibratoToken, d.cfg.InstanceName, time.Second, d.wg))
}

analytics.Start()

for _, i := range d.indexers {
d.startIndexer(i)
}
Expand Down Expand Up @@ -119,7 +120,7 @@ func (d *Daemon) reportStats() {
log := logrus.NewEntry(logrus.StandardLogger())

for k, v := range metrics {
librato.Gauge("indexer."+k, v)
analytics.Gauge("indexer."+k, v)
log = log.WithField(k, v)
}

Expand All @@ -129,7 +130,7 @@ func (d *Daemon) reportStats() {
// Stop stops this daemon
func (d *Daemon) Stop() {
logrus.Info("daemon stopping")
librato.Stop()
analytics.Stop()

close(d.quit)
d.wg.Wait()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ require (
github.com/evalphobia/logrus_sentry v0.8.2
github.com/lib/pq v1.10.5
github.com/nyaruka/ezconf v0.2.1
github.com/nyaruka/gocommon v1.20.0
github.com/nyaruka/librato v1.0.0
github.com/nyaruka/gocommon v1.21.0
github.com/olivere/elastic/v7 v7.0.32
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
Expand All @@ -26,6 +25,7 @@ require (
github.com/mailru/easyjson v0.7.7 // indirect
github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/naoina/toml v0.1.1 // indirect
github.com/nyaruka/librato v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=
github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/nyaruka/ezconf v0.2.1 h1:TDXWoqjqYya1uhou1mAJZg7rgFYL98EB0Tb3+BWtUh0=
github.com/nyaruka/ezconf v0.2.1/go.mod h1:ey182kYkw2MIi4XiWe1FR/mzI33WCmTWuceDYYxgnQw=
github.com/nyaruka/gocommon v1.20.0 h1:qbxRsBBPvpfGbuBq08jlQGxa5t+UZX/YGV7+kR+/moM=
github.com/nyaruka/gocommon v1.20.0/go.mod h1:JrQSLAPo9ezSy1AzsJ1zDr1HW0/eu+aipICJkN/+kpg=
github.com/nyaruka/gocommon v1.21.0 h1:nu7M2cdSPrkqUPdGsEeWX047+neo69H4x+4g/OKpoLM=
github.com/nyaruka/gocommon v1.21.0/go.mod h1:cv9r6amof1gSktfPZROClZhLFzdSIH/N9KbW6Nny4g8=
github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0=
github.com/nyaruka/librato v1.0.0/go.mod h1:pkRNLFhFurOz0QqBz6/DuTFhHHxAubWxs4Jx+J7yUgg=
github.com/olivere/elastic/v7 v7.0.32 h1:R7CXvbu8Eq+WlsLgxmKVKPox0oOwAE/2T9Si5BnvK6E=
Expand Down

0 comments on commit f337d32

Please sign in to comment.