Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metric tag family for too many requests http errors #402

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-402.v2.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 10 additions & 7 deletions conjure-go-client/httpclient/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down