Add round tripper option to have custom status check#3422
Conversation
|
Hi there, Thanks for reaching out! We support configurable error codes for the http client globally via an env var: Can you use this option, or do you specifically need a way to configure error codes per client? Thanks! |
|
I specifically need to configure per client.
2025年4月15日(火) 23:06 Mikayla Toffler ***@***.***>:
… Hi there,
Thanks for reaching out!
We support configurable error codes for the http client *globally* via an
env var: DD_TRACE_HTTP_CLIENT_ERROR_STATUSES, where specified values are
considered errors, and any unspecified values are considered OK. Individual
and range values are supported, e.g:
DD_TRACE_HTTP_CLIENT_ERROR_STATUSES=400,402,404-410.
Can you use this option, or do you specifically need a way to configure
error codes per client?
Thanks!
—
Reply to this email directly, view it on GitHub
<#3422 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5D5RTRDQVLWCF3CW7ZNLD2ZUG5FAVCNFSM6AAAAAB3B5J6PKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMBVGIZTCNBUGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
*mtoffl01* left a comment (DataDog/dd-trace-go#3422)
<#3422 (comment)>
Hi there,
Thanks for reaching out!
We support configurable error codes for the http client *globally* via an
env var: DD_TRACE_HTTP_CLIENT_ERROR_STATUSES, where specified values are
considered errors, and any unspecified values are considered OK. Individual
and range values are supported, e.g:
DD_TRACE_HTTP_CLIENT_ERROR_STATUSES=400,402,404-410.
Can you use this option, or do you specifically need a way to configure
error codes per client?
Thanks!
—
Reply to this email directly, view it on GitHub
<#3422 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5D5RTRDQVLWCF3CW7ZNLD2ZUG5FAVCNFSM6AAAAAB3B5J6PKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMBVGIZTCNBUGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
Hi @barp , In v1, we already provide this functionality via the the RTWithErrorCheck option. Is there a specific reason this doesn’t address your use case? I’m trying to determine whether there’s a gap in the existing support or if this option might have just been overlooked. |
|
Error check (of return value) and status checks are 2 seperate things, since error status is not considered an error the code will go to the status check in which it will always mark it as an error if it's anything between 400-500. In shortRTWithErrorCheck doesn't work in this case as can be seen in .as can be seen that the default status check for clients is dd-trace-go/contrib/net/http/option.go Line 194 in f3d284b |
|
Hi @barp , Thanks for the clarification, though I’m still not entirely sure I understand the issue. Are you looking to treat certain HTTP status codes (e.g., some 4xx responses) not as errors? If so, you can just exclude those codes from your error check logic. Or, maybe you'd like the status evaluation to rely on different criteria entirely—perhaps looking at another part of the response rather than just the HTTP status? I appreciate your patience as we sort this out. Thanks! |
|
I'm looking to not treat all http status codes and all possible errors from a client as not errors (as in I don't want an error reported to data dog error tracking) for every single issue with a specific client I know will have errors. this is because datadog does the error checks in the instrumentated code which I don't have control over and reports those errors no matter if I actually handle those errors. At the current state datadog will report an error even if the code that called the http.Get (for example) function handles the errors correctly. My personal opinion is that error reporting should only happen if the calling user code (not the library code) didn't handle the error. But at the current state getting an error in Error Tracking is unavoidable in go. |
|
I don't want to spam you guys too much, is there an update on this? |
|
@barp It's ok. We've decided to accept this PR in our in-progress |
What does this PR do?
Allow a user of http client to specify what http status codes should be considered errors on a specific http client.
Motivation
I have an http client where I want to have a specific handling for all http status codes and they are never considered an error in my client.
Reviewer's Checklist
golangci-lint runlocally.v2-devbranch and reviewed by @DataDog/apm-go.Unsure? Have a question? Request a review!