Skip to content

Commit

Permalink
Fix rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
snormore committed Sep 26, 2023
1 parent da7437b commit f12599e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/authn/authn.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions pkg/metrics/api-limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package metrics
import (
"context"

"github.com/xmtp/xmtp-node-go/pkg/logging"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
Expand All @@ -21,10 +20,10 @@ var ratelimiterBucketsGaugeView = &view.View{
TagKeys: []tag.Key{bucketsNameKey},
}

func EmitRatelimiterBucketsSize(ctx context.Context, name string, size int) {
func EmitRatelimiterBucketsSize(ctx context.Context, log *zap.Logger, name string, size int) {
err := recordWithTags(ctx, []tag.Mutator{tag.Insert(bucketsNameKey, name)}, ratelimiterBucketsGaugeMeasure.M(int64(size)))
if err != nil {
logging.From(ctx).Warn("recording metric",
log.Warn("recording metric",
zap.String("metric", ratelimiterBucketsGaugeMeasure.Name()),
zap.Error(err))
}
Expand All @@ -39,10 +38,10 @@ var ratelimiterBucketsDeletedCounterView = &view.View{
TagKeys: []tag.Key{bucketsNameKey},
}

func EmitRatelimiterDeletedEntries(ctx context.Context, name string, count int) {
func EmitRatelimiterDeletedEntries(ctx context.Context, log *zap.Logger, name string, count int) {
err := recordWithTags(ctx, []tag.Mutator{tag.Insert(bucketsNameKey, name)}, ratelimiterBucketsDeletedCounterMeasure.M(int64(count)))
if err != nil {
logging.From(ctx).Warn("recording metric",
log.Warn("recording metric",
zap.String("metric", ratelimiterBucketsDeletedCounterMeasure.Name()),
zap.Error(err))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ratelimiter/rate_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func (rl *TokenBucketRateLimiter) Janitor(sweepInterval, expiresAfter time.Durat
func (rl *TokenBucketRateLimiter) sweepAndSwap(expiresAfter time.Duration) (deletedEntries int) {
// Only the janitor writes to oldBuckets (the swap below), so we shouldn't need to rlock it here.
deletedEntries = rl.oldBuckets.deleteExpired(expiresAfter)
metrics.EmitRatelimiterDeletedEntries(rl.ctx, rl.oldBuckets.name, deletedEntries)
metrics.EmitRatelimiterBucketsSize(rl.ctx, rl.oldBuckets.name, len(rl.oldBuckets.buckets))
metrics.EmitRatelimiterDeletedEntries(rl.ctx, rl.log, rl.oldBuckets.name, deletedEntries)
metrics.EmitRatelimiterBucketsSize(rl.ctx, rl.log, rl.oldBuckets.name, len(rl.oldBuckets.buckets))
rl.mutex.Lock()
rl.newBuckets, rl.oldBuckets = rl.oldBuckets, rl.newBuckets
rl.mutex.Unlock()
Expand Down

0 comments on commit f12599e

Please sign in to comment.