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/gin-gonic/gin: incorrect 200 status upon panic recovery hides real problems #1903

Open
seiyab opened this issue Apr 16, 2023 · 3 comments
Labels
ack apm:ecosystem contrib/* related feature requests or bugs bug unintended behavior that has to be fixed

Comments

@seiyab
Copy link

seiyab commented Apr 16, 2023

I'm not sure that this issue is a bug report, a feature request or something else.
Anyway, I think the current behavior can be problematic under practical situations.
Indeed, I couldn't find failed requests when an incident happened.

if status == 0 {
statusStr = "200"

Version of dd-trace-go

v1.49.1

Describe what happened:
Trace for a request that returns 500 error was recorded as 200.

Describe what you expected:
It is recorded as 500, or a special one like "unknown".

Steps to reproduce the issue:

  1. Use gin and its Recovery middleware.
    • NOTE: We want to use Recovery before dd-trace, because we want to recover not only when handler panics but also when dd-trace panics.
  2. Let handler panic.

dd-trace sees status code 0 and record it as 200.
Then, Recovery middleware sets status code 500.

Additional environment details (Version of Go, Operating System, etc.): N/A

History that I investigated

@seiyab
Copy link
Author

seiyab commented May 12, 2023

Anyone?

@katiehockman
Copy link
Contributor

@Julio-Guerra it looks like this is something that changed ~a year ago based on a PR you contributed. The current code uses the ResponseWriter's status code to determine the http.status_code, which isn't playing nicely with Recovery middleware. LMK if this is something you'd like to look into, or if you want to pass ownership over to @DataDog/apm-ecosystems

@katiehockman katiehockman added ack bug unintended behavior that has to be fixed labels May 15, 2023
@katiehockman katiehockman changed the title Handling status code 0 as 200 is confusing in some cases. contrib/gin-gonic/gin: incorrect 200 status upon panic recovery hides real problems May 15, 2023
@seiyab
Copy link
Author

seiyab commented Aug 1, 2023

Any update?

@katiehockman katiehockman added the apm:ecosystem contrib/* related feature requests or bugs label Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack apm:ecosystem contrib/* related feature requests or bugs bug unintended behavior that has to be fixed
Projects
None yet
Development

No branches or pull requests

2 participants