From f337d3211f6deb651375d24b4f72fb175f1ee539 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Thu, 26 May 2022 13:59:22 -0500 Subject: [PATCH] Use analytics package from gocommon instead of librato directly --- daemon.go | 11 ++++++----- go.mod | 4 ++-- go.sum | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/daemon.go b/daemon.go index b57b7d1..8831075 100644 --- a/daemon.go +++ b/daemon.go @@ -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" ) @@ -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) } @@ -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) } @@ -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() diff --git a/go.mod b/go.mod index 6dcf8ab..b51636b 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index b7060e5..5a7e4fd 100644 --- a/go.sum +++ b/go.sum @@ -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=