From fafb794bec9cdb511d86d190bc65a49daf5149d8 Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Mon, 16 Dec 2024 17:45:02 +0200 Subject: [PATCH] Remove librato OB --- backends/rapidpro/backend.go | 15 +-------------- backends/rapidpro/backend_test.go | 2 +- backends/rapidpro/contact.go | 2 -- sender.go | 3 --- server.go | 17 ----------------- 5 files changed, 2 insertions(+), 37 deletions(-) diff --git a/backends/rapidpro/backend.go b/backends/rapidpro/backend.go index 8cbcb5599..75fd388af 100644 --- a/backends/rapidpro/backend.go +++ b/backends/rapidpro/backend.go @@ -26,7 +26,6 @@ import ( "github.com/jmoiron/sqlx" "github.com/nyaruka/courier" "github.com/nyaruka/courier/queue" - "github.com/nyaruka/gocommon/analytics" "github.com/nyaruka/gocommon/aws/cwatch" "github.com/nyaruka/gocommon/aws/dynamo" "github.com/nyaruka/gocommon/aws/s3x" @@ -783,7 +782,6 @@ func (b *backend) Heartbeat() error { b.stats.dbWaitCount = dbStats.WaitCount b.stats.redisWaitDuration = redisStats.WaitDuration b.stats.redisWaitCount = redisStats.WaitCount - dims := []cwtypes.Dimension{ {Name: aws.String("Host"), Value: aws.String(b.config.InstanceID)}, {Name: aws.String("App"), Value: aws.String("courier")}, @@ -858,18 +856,7 @@ func (b *backend) Heartbeat() error { slog.Error("error putting metrics", "error", err) } - analytics.Gauge("courier.db_busy", float64(dbStats.InUse)) - analytics.Gauge("courier.db_idle", float64(dbStats.Idle)) - analytics.Gauge("courier.db_wait_ms", float64(dbWaitDurationInPeriod/time.Millisecond)) - analytics.Gauge("courier.db_wait_count", float64(dbWaitCountInPeriod)) - analytics.Gauge("courier.redis_active", float64(redisStats.ActiveCount)) - analytics.Gauge("courier.redis_idle", float64(redisStats.IdleCount)) - analytics.Gauge("courier.redis_wait_ms", float64(redisWaitDurationInPeriod/time.Millisecond)) - analytics.Gauge("courier.redis_wait_count", float64(redisWaitCountInPeriod)) - analytics.Gauge("courier.bulk_queue", float64(bulkSize)) - analytics.Gauge("courier.priority_queue", float64(prioritySize)) - - slog.Info("current analytics", "db_busy", dbStats.InUse, + slog.Info("current metrics", "db_busy", dbStats.InUse, "db_idle", dbStats.Idle, "db_wait_time", dbWaitDurationInPeriod, "db_wait_count", dbWaitCountInPeriod, diff --git a/backends/rapidpro/backend_test.go b/backends/rapidpro/backend_test.go index e47880902..751eeca75 100644 --- a/backends/rapidpro/backend_test.go +++ b/backends/rapidpro/backend_test.go @@ -769,7 +769,7 @@ func (ts *BackendTestSuite) TestHealth() { } func (ts *BackendTestSuite) TestHeartbeat() { - // TODO make analytics abstraction layer so we can test what we report + // TODO make metrics abstraction layer so we can test what we report ts.NoError(ts.b.Heartbeat()) } diff --git a/backends/rapidpro/contact.go b/backends/rapidpro/contact.go index d291e4b0d..204783eba 100644 --- a/backends/rapidpro/contact.go +++ b/backends/rapidpro/contact.go @@ -14,7 +14,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/jmoiron/sqlx" "github.com/nyaruka/courier" - "github.com/nyaruka/gocommon/analytics" "github.com/nyaruka/gocommon/dbutil" "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/gocommon/uuids" @@ -220,7 +219,6 @@ func contactForURN(ctx context.Context, b *backend, org OrgID, channel *Channel, contact.URNID_ = contactURN.ID // log that we created a new contact to librato - analytics.Gauge("courier.new_contact", float64(1)) dims := []types.Dimension{ {Name: aws.String("ChannelType"), Value: aws.String(string(channel.ChannelType()))}, {Name: aws.String("App"), Value: aws.String("courier")}, diff --git a/sender.go b/sender.go index 0224f8ee6..1f98b4283 100644 --- a/sender.go +++ b/sender.go @@ -10,7 +10,6 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" "github.com/nyaruka/courier/utils/clogs" - "github.com/nyaruka/gocommon/analytics" "github.com/nyaruka/gocommon/urns" ) @@ -342,7 +341,6 @@ func (w *Sender) sendMessage(msg MsgOut) { // report to librato if status.Status() == MsgStatusErrored || status.Status() == MsgStatusFailed { - analytics.Gauge(fmt.Sprintf("courier.msg_send_error_%s", msg.Channel().ChannelType()), secondDuration) backend.CloudWatchService().Send(sendCTX, types.MetricDatum{ MetricName: aws.String("MsgSendError"), Dimensions: dims, @@ -351,7 +349,6 @@ func (w *Sender) sendMessage(msg MsgOut) { }) } else { - analytics.Gauge(fmt.Sprintf("courier.msg_send_%s", msg.Channel().ChannelType()), secondDuration) backend.CloudWatchService().Send(sendCTX, types.MetricDatum{ MetricName: aws.String("MsgSend"), Dimensions: dims, diff --git a/server.go b/server.go index 8e1e05b9f..be3001722 100644 --- a/server.go +++ b/server.go @@ -9,7 +9,6 @@ import ( "log" "log/slog" "net/http" - "os" "runtime/debug" "slices" "sort" @@ -22,7 +21,6 @@ import ( "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/nyaruka/courier/utils/clogs" - "github.com/nyaruka/gocommon/analytics" "github.com/nyaruka/gocommon/httpx" "github.com/nyaruka/gocommon/jsonx" ) @@ -94,14 +92,6 @@ func NewServerWithLogger(config *Config, backend Backend, logger *slog.Logger) S // if it encounters any unrecoverable (or ignorable) error, though its bias is to move forward despite // connection errors func (s *server) Start() error { - // configure librato if we have configuration options for it - host, _ := os.Hostname() - if s.config.LibratoUsername != "" { - analytics.RegisterBackend(analytics.NewLibrato(s.config.LibratoUsername, s.config.LibratoToken, host, time.Second, s.waitGroup)) - } - - analytics.Start() - // start our backend err := s.backend.Start() if err != nil { @@ -197,8 +187,6 @@ func (s *server) Stop() error { return err } - analytics.Stop() - // wait for everything to stop s.waitGroup.Wait() @@ -332,7 +320,6 @@ func (s *server) channelHandleWrapper(handler ChannelHandler, handlerFunc Channe Value: aws.Float64(float64(secondDuration)), Unit: types.StandardUnitSeconds, }) - analytics.Gauge(fmt.Sprintf("courier.channel_error_%s", channel.ChannelType()), secondDuration) } else { s.Backend().CloudWatchService().Send(ctx, types.MetricDatum{ MetricName: aws.String("ChannelIgnored"), @@ -340,7 +327,6 @@ func (s *server) channelHandleWrapper(handler ChannelHandler, handlerFunc Channe Value: aws.Float64(float64(secondDuration)), Unit: types.StandardUnitSeconds, }) - analytics.Gauge(fmt.Sprintf("courier.channel_ignored_%s", channel.ChannelType()), secondDuration) } } @@ -354,7 +340,6 @@ func (s *server) channelHandleWrapper(handler ChannelHandler, handlerFunc Channe Value: aws.Float64(float64(secondDuration)), Unit: types.StandardUnitSeconds, }) - analytics.Gauge(fmt.Sprintf("courier.msg_receive_%s", channel.ChannelType()), secondDuration) LogMsgReceived(r, e) case StatusUpdate: clog.SetAttached(true) @@ -364,7 +349,6 @@ func (s *server) channelHandleWrapper(handler ChannelHandler, handlerFunc Channe Value: aws.Float64(float64(secondDuration)), Unit: types.StandardUnitSeconds, }) - analytics.Gauge(fmt.Sprintf("courier.msg_status_%s", channel.ChannelType()), secondDuration) LogMsgStatusReceived(r, e) case ChannelEvent: s.Backend().CloudWatchService().Send(ctx, types.MetricDatum{ @@ -372,7 +356,6 @@ func (s *server) channelHandleWrapper(handler ChannelHandler, handlerFunc Channe Dimensions: dims, Value: aws.Float64(float64(secondDuration)), Unit: types.StandardUnitSeconds}) - analytics.Gauge(fmt.Sprintf("courier.evt_receive_%s", channel.ChannelType()), secondDuration) LogChannelEventReceived(r, e) } }