Skip to content

Commit c3da1ca

Browse files
cheuktbenjirewis
andauthored
APP-14482 - Downgrade logs for signaling/ratelimiting (#519)
Co-authored-by: Benjamin Rewis <[email protected]>
1 parent 44e3ae1 commit c3da1ca

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

rpc/wrtc_call_queue_mongodb.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ func (queue *mongoDBWebRTCCallQueue) operatorLivenessLoop() {
620620
//nolint:goconst
621621
reason = "other"
622622
}
623-
queue.logger.Errorw("failed to update operator document for self", "error", err)
623+
queue.logger.Infow("failed to update operator document for self", "error", err)
624624
}
625625
operatorsCollUpdateFailures.Inc(queue.operatorID, reason)
626626
} else if result.UpsertedCount == 1 {
@@ -738,7 +738,7 @@ func (queue *mongoDBWebRTCCallQueue) changeStreamManager() {
738738
if err != nil {
739739
callChangeStreamFailures.Inc(queue.operatorID)
740740
queue.csManagerSeq.Add(1)
741-
queue.logger.Errorw("failed to create calls change stream", "error", err)
741+
queue.logger.Infow("failed to create calls change stream", "error", err)
742742
continue
743743
}
744744

rpc/wrtc_rate_limiter.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ var rateLimitDenials = statz.NewCounter1[string]("signaling/rate_limits_denials"
2828
},
2929
})
3030

31+
var rateLimitErrors = statz.NewCounter1[string]("signaling/rate_limit_errors", statz.MetricConfig{
32+
Description: "Total number of errors while applying the rate limit.",
33+
Unit: units.Dimensionless,
34+
Labels: []statz.Label{
35+
{Name: "reason", Description: "Reason that applying the rate limit failed."},
36+
},
37+
})
38+
3139
// Database configuration and collection names for MongoDB rate limiter.
3240
var (
3341
mongodbWebRTCRateLimiterCollName = "rate_limiter"
@@ -102,8 +110,10 @@ func (rl *MongoDBRateLimiter) Allow(ctx context.Context, key string) error {
102110
}},
103111
options.Update().SetUpsert(true))
104112
if err != nil {
105-
rl.logger.Errorw("rate limit doc existence check failed", "error", err, "key", key)
106-
return err
113+
// to not erroneously rate limit requests, we log the error but do not return the error.
114+
rl.logger.Infow("rate limit doc existence check failed", "error", err, "key", key)
115+
rateLimitErrors.Inc("existence_check_failed")
116+
return nil
107117
}
108118

109119
// Filter: only match if request count within the most recent window for this key is < MaxRequests
@@ -176,8 +186,10 @@ func (rl *MongoDBRateLimiter) Allow(ctx context.Context, key string) error {
176186

177187
result, err := rl.rateLimitColl.UpdateOne(ctx, filter, update)
178188
if err != nil {
179-
rl.logger.Errorw("rate limit operation failed", "error", err, "key", key)
180-
return err
189+
// to not erroneously rate limit requests, we log the error but do not return the error.
190+
rl.logger.Infow("rate limit operation failed", "error", err, "key", key)
191+
rateLimitErrors.Inc("update_operation_failed")
192+
return nil
181193
}
182194

183195
// No match means rate limit exceeded

0 commit comments

Comments
 (0)