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

contrib/internal/httptrace: proposal: Add option to ignore setting errors for 5xx HTTP status codes #2390

Open
kazukousen opened this issue Nov 28, 2023 · 6 comments
Assignees
Labels
apm:ecosystem contrib/* related feature requests or bugs enhancement quick change/addition that does not need full team approval proposal/accepted Accepted proposals proposal more in depth change that requires full team approval

Comments

@kazukousen
Copy link

Only errors located in the uppermost service span are processed by ErrorTracking.

We use tracer.SetTag(ext.Error, err) to record error in the uppermost service span.

However, the gorilla/mux tracer we use which internally uses http tracer, also overrides the error with tracer.SetTag() when the HTTP Errors (5xx) occur.

if status >= 500 && status < 600 {
s.SetTag(ext.Error, fmt.Errorf("%s: %s", statusStr, http.StatusText(status)))
}

As a result, ErrorTracking groups all errors into a generic 5xx error issue, displays examples like 500: Internel Server Error in its web UI.
image

We'd like discuss about adding an option to ignore setting the error. this could be implemented as follows:

if !cfg.disabledSetHTTPError && status >= 500 && status < 600 {
	s.SetTag(ext.Error, fmt.Errorf("%s: %s", statusStr, http.StatusText(status)))
}
@kazukousen kazukousen added the enhancement quick change/addition that does not need full team approval label Nov 28, 2023
@ajgajg1134 ajgajg1134 added the proposal more in depth change that requires full team approval label Nov 28, 2023
@katiehockman katiehockman added the apm:ecosystem contrib/* related feature requests or bugs label Nov 28, 2023
@kazukousen
Copy link
Author

I worked on #2432

@ajgajg1134 @katiehockman Hi, folks. I would be grateful if you could take some time to review it.

@katiehockman
Copy link
Contributor

Hi @kazukousen, thanks for filing this issue. We've been discussing this, and wonder if we should instead verify that there is not already an error status code and error tag on the span before we overwrite it. We're not sure that there is a good use case for overriding it, so rather than make this configurable, we should probably just fix this. Let us know what you think, and if this would fix your issue.

We'll work on this and add some tests, and get back in touch with you.

@katiehockman
Copy link
Contributor

We're discussing adding a Tag(key string) interface{} method to the Span struct, which given a key would return the tag value. This would allow us to check if there is already an error tag here, and if there is, either 1) don't change the error or 2) concatenate the error so it doesn't get lost. That will also avoid needing additional configuration.

@kazukousen
Copy link
Author

Hi @katiehockman, Thank you for your reply.

We've been discussing this, and wonder if we should instead verify that there is not already an error status code and error tag on the span before we overwrite it. We're not sure that there is a good use case for overriding it, so rather than make this configurable, we should probably just fix this. Let us know what you think, and if this would fix your issue.

That's make sense for us. It is clear. Thanks!

@darccio darccio added the proposal/accepted Accepted proposals label Jul 9, 2024
@threesquared
Copy link

Was anything ever done about this? It seems like #2523 was eventually reverted?

We are also using the gorilla/mux tracer and all the errors we see are this generic 500: Internel Server Error with a very unhelpful stack trace.

@mtoffl01 mtoffl01 self-assigned this Oct 29, 2024
@mtoffl01
Copy link
Contributor

mtoffl01 commented Oct 29, 2024

Hi there,

We are still discussing how to handle the scenario where the tracer assigns an error to span that already has one. In the meantime, you can technically disable the tracer's automatic error status setter with the DD_TRACE_HTTP_SERVER_ERROR_STATUSES option, as of of v1.69.0. If set to a value that does not show up in your request/response pattern, the tracer will never set an error status on your HTTP server spans, effectively never overwriting your custom error. Note that this would apply to multiple HTTP integrations.

Some HTTP integrations support integration-level error code configuration, e.g, negroni and work is currently in progress to support this in the net/http contrib package. This is not yet supported nor in progress for the gorilla/mux integration. If you believe integration-level support for gorilla/mux would help you, let us know and we can consider prioritizing it as a temporary fix for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs enhancement quick change/addition that does not need full team approval proposal/accepted Accepted proposals proposal more in depth change that requires full team approval
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants