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

Body always empty? #223

Closed
gionn opened this issue Jul 1, 2016 · 6 comments
Closed

Body always empty? #223

gionn opened this issue Jul 1, 2016 · 6 comments

Comments

@gionn
Copy link

gionn commented Jul 1, 2016

Hi,

it looks like that in our setup raven is not capturing any http body in the context of the logged exception, while other things like cookies, headers and environment variables are there.

Any suggestions on how to debug this issue?

@bretthoerner
Copy link

It looks like we don't attempt to extract the body in HttpInterface.

In my understanding: one issue with ServletRequest is that the request body can only be read once, and presumably it has been read by you or your framework before an exception is thrown over to Raven. We do have RavenServletRequestListener, but it doesn't seem like we have a chance to wrap the request in something to cache the response there.

Would love anyone else's thoughts on this. I'll see what else I can come up with.

@gionn
Copy link
Author

gionn commented Jul 1, 2016

Correct, we already have a listener to cache the body stream for logging purposes, maybe there is some way via Raven Java API to set such body so I can have it on my exceptions?

@bretthoerner
Copy link

Since you have the data available from your listener you should be able to make it work. Sadly it seems like it might be kind of annoying,

We attach the HttpInterface and HttpInterfaceBinding here: https://github.com/getsentry/raven-java/blob/master/raven/src/main/java/com/getsentry/raven/DefaultRavenFactory.java#L228-L231

I think you'd need your own RavenFactory and your own HttpInterface and HttpInterfaceBinding in the current implementation. :( This is because interfaceBindings are not run in a specified order (this is intentional) and so if you just added your own simple interface it may be overwritten by the existing HTTP binding.

I wonder what a more general solution could be...

@bretthoerner
Copy link

To be clear, I'd love your input here. I wonder if many users keep a cached copy of the body around because it can only be read once. Maybe some easy way for those users to hand off the body to us...?

It'd be great to solve this for everyone, even those without the cached body. I don't know what we can do given the interface though.

@bretthoerner
Copy link

Did you have any luck with this @gionn ?

@gionn
Copy link
Author

gionn commented Jul 15, 2016

Yeah, I've ended up using slf4j MDC facility to set some context tags, one of them contains the body of the request that generated an exception.

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

2 participants