From 0388e028c95ae16f5ca33024e1d07cca525c072d Mon Sep 17 00:00:00 2001 From: Samuel Guilhem-Ducleon Date: Tue, 8 Nov 2022 11:50:56 -0500 Subject: [PATCH 1/4] too many requests tag --- conjure-go-client/httpclient/metrics.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/conjure-go-client/httpclient/metrics.go b/conjure-go-client/httpclient/metrics.go index 7837589d..ea076f4a 100644 --- a/conjure-go-client/httpclient/metrics.go +++ b/conjure-go-client/httpclient/metrics.go @@ -50,13 +50,14 @@ var ( MetricTagConnectionNew = metrics.MustNewTag("reused", "false") MetricTagConnectionReused = metrics.MustNewTag("reused", "true") - metricTagFamily1xx = metrics.MustNewTag(metricTagFamily, "1xx") - metricTagFamily2xx = metrics.MustNewTag(metricTagFamily, "2xx") - metricTagFamily3xx = metrics.MustNewTag(metricTagFamily, "3xx") - metricTagFamily4xx = metrics.MustNewTag(metricTagFamily, "4xx") - metricTagFamily5xx = metrics.MustNewTag(metricTagFamily, "5xx") - metricTagFamilyOther = metrics.MustNewTag(metricTagFamily, "other") - metricTagFamilyTimeout = metrics.MustNewTag(metricTagFamily, "timeout") + metricTagFamily1xx = metrics.MustNewTag(metricTagFamily, "1xx") + metricTagFamily2xx = metrics.MustNewTag(metricTagFamily, "2xx") + metricTagFamily3xx = metrics.MustNewTag(metricTagFamily, "3xx") + metricTagFamily4xx = metrics.MustNewTag(metricTagFamily, "4xx") + metricTagFamily5xx = metrics.MustNewTag(metricTagFamily, "5xx") + metricTagFamilyOther = metrics.MustNewTag(metricTagFamily, "other") + metricTagFamilyTimeout = metrics.MustNewTag(metricTagFamily, "timeout") + metricTagFamilyTooManyRequests = metrics.MustNewTag(metricTagFamily, "too-many-requests") ) // A TagsProvider returns metrics tags based on an http round trip. @@ -146,6 +147,8 @@ func tagStatusFamily(_ *http.Request, resp *http.Response, respErr error) metric switch { case isTimeoutError(respErr): return metrics.Tags{metricTagFamilyTimeout} + case resp.StatusCode == 429: + return metrics.Tags{metricTagFamilyTooManyRequests} case resp == nil, resp.StatusCode < 100, resp.StatusCode > 599: return metrics.Tags{metricTagFamilyOther} case resp.StatusCode < 200: From 207810d8809d5e63b6a3eba69c22f45490de704f Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Tue, 8 Nov 2022 16:52:25 +0000 Subject: [PATCH 2/4] Add generated changelog entries --- changelog/@unreleased/pr-402.v2.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/@unreleased/pr-402.v2.yml diff --git a/changelog/@unreleased/pr-402.v2.yml b/changelog/@unreleased/pr-402.v2.yml new file mode 100644 index 00000000..54752563 --- /dev/null +++ b/changelog/@unreleased/pr-402.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Add metric tag family for too many requests http errors + links: + - https://github.com/palantir/conjure-go-runtime/pull/402 From 50e488a3546e47caf77e49a17a8c9a31b28d78a4 Mon Sep 17 00:00:00 2001 From: Samuel Guilhem-Ducleon Date: Tue, 8 Nov 2022 12:11:00 -0500 Subject: [PATCH 3/4] fix tests --- conjure-go-client/httpclient/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conjure-go-client/httpclient/metrics.go b/conjure-go-client/httpclient/metrics.go index ea076f4a..90a85ffa 100644 --- a/conjure-go-client/httpclient/metrics.go +++ b/conjure-go-client/httpclient/metrics.go @@ -147,8 +147,6 @@ func tagStatusFamily(_ *http.Request, resp *http.Response, respErr error) metric switch { case isTimeoutError(respErr): return metrics.Tags{metricTagFamilyTimeout} - case resp.StatusCode == 429: - return metrics.Tags{metricTagFamilyTooManyRequests} case resp == nil, resp.StatusCode < 100, resp.StatusCode > 599: return metrics.Tags{metricTagFamilyOther} case resp.StatusCode < 200: @@ -157,6 +155,8 @@ func tagStatusFamily(_ *http.Request, resp *http.Response, respErr error) metric return metrics.Tags{metricTagFamily2xx} case resp.StatusCode < 400: return metrics.Tags{metricTagFamily3xx} + case resp.StatusCode == 429: + return metrics.Tags{metricTagFamilyTooManyRequests} case resp.StatusCode < 500: return metrics.Tags{metricTagFamily4xx} case resp.StatusCode < 600: From f05f782e083a15b2ab03537c69811217f2294f68 Mon Sep 17 00:00:00 2001 From: Samuel Guilhem-Ducleon Date: Tue, 8 Nov 2022 12:14:06 -0500 Subject: [PATCH 4/4] handle 408 --- conjure-go-client/httpclient/metrics.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conjure-go-client/httpclient/metrics.go b/conjure-go-client/httpclient/metrics.go index 90a85ffa..583594f0 100644 --- a/conjure-go-client/httpclient/metrics.go +++ b/conjure-go-client/httpclient/metrics.go @@ -155,6 +155,8 @@ func tagStatusFamily(_ *http.Request, resp *http.Response, respErr error) metric return metrics.Tags{metricTagFamily2xx} case resp.StatusCode < 400: return metrics.Tags{metricTagFamily3xx} + case resp.StatusCode == 408: + return metrics.Tags{metricTagFamilyTimeout} case resp.StatusCode == 429: return metrics.Tags{metricTagFamilyTooManyRequests} case resp.StatusCode < 500: