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

Refactor metrics so that everything is sent from Heartbeat in the backend #818

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

rowanseymour
Copy link
Member

No description provided.

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 84.25926% with 17 lines in your changes missing coverage. Please review.

Project coverage is 74.54%. Comparing base (68d55f9) to head (aa5809d).

Files with missing lines Patch % Lines
backends/rapidpro/stats.go 86.25% 9 Missing and 2 partials ⚠️
backends/rapidpro/backend.go 78.26% 3 Missing and 2 partials ⚠️
test/backend.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #818   +/-   ##
=======================================
  Coverage   74.54%   74.54%           
=======================================
  Files         111      112    +1     
  Lines       13243    13271   +28     
=======================================
+ Hits         9872     9893   +21     
- Misses       2653     2658    +5     
- Partials      718      720    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rowanseymour rowanseymour marked this pull request as ready for review December 17, 2024 22:50
@@ -106,9 +106,6 @@ type Backend interface {

// RedisPool returns the redisPool for this backend
RedisPool() *redis.Pool

// CloudWatch return the CloudWatch service for this backend
CloudWatch() *cwatch.Service
Copy link
Member Author

Choose a reason for hiding this comment

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

Cloudwatch is now completely internal to the RP backend.. which seems right

cwatch.Datum("DBConnectionsInUse", float64(dbStats.InUse), cwtypes.StandardUnitCount, hostDim),
cwatch.Datum("DBConnectionWaitDuration", float64(dbWaitDurationInPeriod/time.Millisecond), cwtypes.StandardUnitMilliseconds, hostDim),
cwatch.Datum("DBConnectionWaitDuration", float64(dbWaitDurationInPeriod/time.Second), cwtypes.StandardUnitSeconds, hostDim),
Copy link
Member Author

Choose a reason for hiding this comment

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

we're using seconds everywhere

@@ -131,6 +129,8 @@ func newBackend(cfg *courier.Config) courier.Backend {
receivedExternalIDs: redisx.NewIntervalHash("seen-external-ids", time.Hour*24, 2), // 24 - 48 hours
sentIDs: redisx.NewIntervalSet("sent-ids", time.Hour, 2), // 1 - 2 hours
sentExternalIDs: redisx.NewIntervalHash("sent-external-ids", time.Hour, 2), // 1 - 2 hours

stats: NewStatsCollector(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to call Heartbeat when the backend stop or in backend cleanup so we are sure all the stats at that time are sent? it seems the stats in the last minute not yet send will be lost

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldn't worry about losing some metrics here and there.. but I do want to move the heartbeat stuff completely inside the backend in another pr and could think about sending final metrics when stopping courier.

@rowanseymour rowanseymour merged commit 9ce2da7 into main Dec 18, 2024
7 checks passed
@rowanseymour rowanseymour deleted the metrics_v2 branch December 18, 2024 13:44
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 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