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

Optionally log request & response bodies? #32

Closed
bootstraponline opened this issue Aug 27, 2015 · 6 comments · Fixed by #34
Closed

Optionally log request & response bodies? #32

bootstraponline opened this issue Aug 27, 2015 · 6 comments · Fixed by #34

Comments

@bootstraponline
Copy link

The body of requests and responses are not logged for performance reasons (chunked encoding).

https://github.com/google/martian/wiki/Modifier-Reference#logging

It'd be nice if one could optionally log request & response bodies. I'm looking for an easy way to dump requests/responses as JSON (ideally HAR).

@admtnnr
Copy link
Contributor

admtnnr commented Aug 27, 2015

Thanks for the issue! 👍

I've updated the docs to reflect some recent changes in log.Logger that enable it to log message bodies, optionally dechunking and decompressing them so that they are readable in the log output.

We actually have an implementation of a HAR logger for Martian internally that we held off on open sourcing because it's not entirely to spec. Some places of the spec are vague and there are some fields we just haven't implemented. We can look into prioritizing open sourcing it.

I'd like to understand your use case a bit more though. What problem are you trying to solve with HAR logs? Do you need HAR specifically or would any log formatted as JSON work? I ask because we've talked about doing a more lightweight JSON log format for Martian in the past.

@bootstraponline
Copy link
Author

I'd be very interested in a HAR logger even if it's not entirely to spec. My use case is Selenium web testing. Typically I use browsermob-proxy to capture HAR files. This enables testing a bunch of scenarios that standard selenium is not able to handle.

@admtnnr
Copy link
Contributor

admtnnr commented Aug 27, 2015

Okay, cool. We'll work on cleaning up the HAR implementation.

We built a Verifier API for Martian that was intended to solve these use cases without requiring users to reimplement the verification logic across languages/platforms and enable verifications to be made for requests where loading the entire message body into memory before asserting may not be feasible (video streaming, large file downloads). We have a couple verifiers built in already; here's one for verifying status codes.

We have a couple open issues for making the API better (#27, #28) and would love feedback if you have any.

@bootstraponline
Copy link
Author

The issue I have with verifiers is with one of my projects, I'm trying to compare the HAR files across webdriver sessions. To do that I need to persist the request/response information to disk. The approach is similar to VCR.

@admtnnr
Copy link
Contributor

admtnnr commented Aug 27, 2015

Sounds good. Thanks for the insight. 👍

@bootstraponline
Copy link
Author

Thanks for adding HAR support!

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

Successfully merging a pull request may close this issue.

2 participants