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

Empty httpResponseStatus with Nrgin #90

Closed
paulogustavosouza opened this issue May 31, 2019 · 4 comments
Closed

Empty httpResponseStatus with Nrgin #90

paulogustavosouza opened this issue May 31, 2019 · 4 comments

Comments

@paulogustavosouza
Copy link

paulogustavosouza commented May 31, 2019

Hi guys, how are you?

So, I'm trying using new relic agent with gin and I'm using your nrgin adapter but something wrong are happing.

The http status code is always empty when I just send an empty response.

Captura de Tela 2019-05-31 às 18 42 30

Why do you don't set the http status code when WriteHeader is called ?

Look this code:

func (w *replacementResponseWriter) WriteHeader(code int) {
	w.code = code
	w.ResponseWriter.WriteHeader(code)
}

So if I wanna an empty response body with some status code new relic doesn't will save the status code because gin just call WriteHeader:

Code: https://github.com/gin-gonic/gin/blob/master/context.go
Line: 730

// Status sets the HTTP response code.
func (c *Context) Status(code int) {
	c.writermem.WriteHeader(code)
}

What we can do about it ?

@willnewrelic
Copy link

Hi @paulogustavosouza !

I've opened a PR fix against Gin here: gin-gonic/gin#1606 Perhaps you could encourage them to merge it too! =D

@paulogustavosouza
Copy link
Author

Heeyyy, since gin guys already merged the issue gin-gonic/gin#1606, will you work in this issue?

@purple4reina
Copy link
Contributor

Hey @paulogustavosouza,

Thanks for the ping! I've confirmed that gin-gonic/gin#1606 allows users to capture the status code when a response body is written. I've also confirmed your issue here, that when just setting the status (and not response body) you are not seeing the status code.

I'll go ahead and take a look now at what it will take to get this fixed for you. I'll keep you up to date with what I find.

For reference, I'm using this handler for testing:

func handler(c *gin.Context) {
    c.Status(500)
}

@purple4reina
Copy link
Contributor

Hello again @paulogustavosouza,

We have tracked down the issue of the missing response status codes. The fix will be released with the next version of the agent. Thanks so much for bringing this to our attention!

I'm going to close this issue, but if you have any questions or concerns, please go ahead and reopen it. We're always happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants