From bb943ec6563fde6a60beeffdadeaa907890d131a Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Tue, 5 Nov 2024 17:10:16 +0100 Subject: [PATCH] local rate limit metric --- proxy/metrics.go | 5 +++++ proxy/receiver_api.go | 1 + 2 files changed, 6 insertions(+) diff --git a/proxy/metrics.go b/proxy/metrics.go index a8a501f..6bc4460 100644 --- a/proxy/metrics.go +++ b/proxy/metrics.go @@ -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 ( @@ -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() diff --git a/proxy/receiver_api.go b/proxy/receiver_api.go index 0645c81..fc46a2a 100644 --- a/proxy/receiver_api.go +++ b/proxy/receiver_api.go @@ -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) } }