Skip to content

Commit

Permalink
local rate limit metric
Browse files Browse the repository at this point in the history
  • Loading branch information
dvush committed Nov 5, 2024
1 parent 96285e6 commit bb943ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions proxy/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
confighubErrorsCounter = metrics.NewCounter("orderflow_proxy_confighub_errors")

shareQueueInternalErrors = metrics.NewCounter("orderflow_proxy_share_queue_internal_errors")
apiLocalRateLimits = metrics.NewCounter("orderflow_proxy_api_local_rate_limits")
)

const (
Expand All @@ -39,6 +40,10 @@ func incAPIDuplicateRequestsByPeer(peer string) {
metrics.GetOrCreateCounter(l).Inc()
}

func incAPILocalRateLimits() {
apiLocalRateLimits.Inc()
}

func incShareQueueTotalRequests(peer string) {
l := fmt.Sprintf(shareQueuePeerTotalRequestsLabel, peer)
metrics.GetOrCreateCounter(l).Inc()
Expand Down
1 change: 1 addition & 0 deletions proxy/receiver_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ func (prx *ReceiverProxy) HandleParsedRequest(ctx context.Context, parsedRequest
if !parsedRequest.publicEndpoint {
err := prx.localAPIRateLimiter.Wait(ctx)
if err != nil {
incAPILocalRateLimits()
return errors.Join(errRateLimiting, err)
}
}
Expand Down

0 comments on commit bb943ec

Please sign in to comment.