From fe0642c88d18f41a1a85bd8ce440b85cdd88a632 Mon Sep 17 00:00:00 2001 From: Vaibhav Kamra Date: Tue, 7 Mar 2023 18:32:22 -0800 Subject: [PATCH] Log throttling headers --- src/internal/connector/graph/service.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/internal/connector/graph/service.go b/src/internal/connector/graph/service.go index 58cfab18e..c52c7e238 100644 --- a/src/internal/connector/graph/service.go +++ b/src/internal/connector/graph/service.go @@ -30,6 +30,9 @@ const ( defaultMaxRetries = 3 defaultDelay = 3 * time.Second absoluteMaxDelaySeconds = 180 + rateLimitHeader = "RateLimit-Limit" + rateRemainingHeader = "RateLimit-Remaining" + rateResetHeader = "RateLimit-Reset" ) // AllMetadataFileNames produces the standard set of filenames used to store graph @@ -313,7 +316,12 @@ func (handler *LoggingMiddleware) Intercept( } else { // special case for supportability: log all throttling cases. if resp.StatusCode == http.StatusTooManyRequests { - logger.Ctx(ctx).Infow("graph api throttling", "method", req.Method, "url", req.URL) + logger.Ctx(ctx).Infow("graph api throttling", + "method", req.Method, + "url", req.URL, + "limit", resp.Header.Get(rateLimitHeader), + "remaining", resp.Header.Get(rateRemainingHeader), + "reset", resp.Header.Get(rateResetHeader)) } else if resp.StatusCode == http.StatusBadRequest { respDump, _ := httputil.DumpResponse(resp, true) logger.Ctx(ctx).Infow(