Skip to content
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

Merged
merged 2 commits into from
Dec 17, 2024
Merged

Use Cloudwatch for metrics #813

merged 2 commits into from
Dec 17, 2024

Conversation

norkans7
Copy link
Contributor

No description provided.

@norkans7 norkans7 changed the title Add cw Use Cloudwatch for metrics Dec 16, 2024
@norkans7 norkans7 force-pushed the add-cw branch 3 times, most recently from 35ad354 to f7e53f3 Compare December 16, 2024 15:26
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

Attention: Patch coverage is 80.26316% with 15 lines in your changes missing coverage. Please review.

Project coverage is 74.55%. Comparing base (841af35) to head (7eccede).

Files with missing lines Patch % Lines
server.go 47.05% 9 Missing ⚠️
backends/rapidpro/backend.go 89.65% 2 Missing and 1 partial ⚠️
test/backend.go 57.14% 2 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

@@ -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"
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call this Cloudwatch()

@@ -775,6 +784,80 @@ func (b *backend) Heartbeat() error {
b.stats.redisWaitDuration = redisStats.WaitDuration
b.stats.redisWaitCount = redisStats.WaitCount

dims := []cwtypes.Dimension{
Copy link
Member

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
}

Copy link
Member

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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and stop it later


metrics := []cwtypes.MetricDatum{
cwatch.Datum("DBConnectionsInUse", float64(dbStats.InUse), cwtypes.StandardUnitCount, hostDim, appDim),
cwatch.Datum("DBConnectionsIdle", float64(dbStats.Idle), cwtypes.StandardUnitCount, hostDim, appDim),
Copy link
Member

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")
Copy link
Member

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())),
),
)
Copy link
Member

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...

Copy link
Member

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...

@rowanseymour rowanseymour merged commit e9b8206 into main Dec 17, 2024
7 checks passed
@rowanseymour rowanseymour deleted the add-cw branch December 17, 2024 16:50
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants