-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Cloudwatch for metrics #813
Conversation
35ad354
to
f7e53f3
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #813 +/- ##
==========================================
+ Coverage 74.52% 74.55% +0.02%
==========================================
Files 111 111
Lines 13223 13297 +74
==========================================
+ Hits 9855 9914 +59
- Misses 2651 2664 +13
- Partials 717 719 +2 ☔ View full report in Codecov by Sentry. |
backends/rapidpro/backend_test.go
Outdated
@@ -51,6 +51,8 @@ func testConfig() *courier.Config { | |||
// configure S3 to use a local minio instance | |||
config.AWSAccessKeyID = "root" | |||
config.AWSSecretAccessKey = "tembatemba" | |||
config.CloudwatchNamespace = "Temba" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should just use default value
backend.go
Outdated
@@ -105,6 +106,9 @@ type Backend interface { | |||
|
|||
// RedisPool returns the redisPool for this backend | |||
RedisPool() *redis.Pool | |||
|
|||
// CloudWatchService return the CloudWatch service for this backend | |||
CloudWatchService() *cwatch.Service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this Cloudwatch()
backends/rapidpro/backend.go
Outdated
@@ -775,6 +784,80 @@ func (b *backend) Heartbeat() error { | |||
b.stats.redisWaitDuration = redisStats.WaitDuration | |||
b.stats.redisWaitCount = redisStats.WaitCount | |||
|
|||
dims := []cwtypes.Dimension{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use new util methods in gocommon - cwatch.Dimension
and cwatch.Datum
if err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to call b.cw.StartQueue(time.Second * 3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and stop it later
backends/rapidpro/backend.go
Outdated
|
||
metrics := []cwtypes.MetricDatum{ | ||
cwatch.Datum("DBConnectionsInUse", float64(dbStats.InUse), cwtypes.StandardUnitCount, hostDim, appDim), | ||
cwatch.Datum("DBConnectionsIdle", float64(dbStats.Idle), cwtypes.StandardUnitCount, hostDim, appDim), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I was converting mailroom I decided we can ditch some of these so let's cut this down to https://github.com/nyaruka/mailroom/blob/c3a17019ba55263f229f71efe91a773ee0b05ccb/core/tasks/metrics/cron.go#L52-L55
test/backend.go
Outdated
@@ -83,6 +86,11 @@ func NewMockBackend() *MockBackend { | |||
log.Fatal(err) | |||
} | |||
|
|||
CW, err := cwatch.NewService("root", "tembatemba", "us-east-1", "Temba", "test") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cw
cwtypes.StandardUnitCount, | ||
cwatch.Dimension("ChannelType", string(channel.ChannelType())), | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wanna discuss with @ericnewcomer what is actually useful here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually can merge and remove librato and then tweak these metris afterwards...
No description provided.