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

Capture HTTP headers in results #474

Merged
merged 2 commits into from
Feb 16, 2020
Merged

Capture HTTP headers in results #474

merged 2 commits into from
Feb 16, 2020

Conversation

rs
Copy link
Contributor

@rs rs commented Feb 7, 2020

Headers are written in wire format. CSV output uses base64 to encode
headers.

Fixes #303

Headers are written in wire format. CSV output uses base64 to encode
headers.

Fixes tsenart#303
@rs rs requested review from tsenart and xla as code owners February 7, 2020 02:50
lib/attack.go Outdated
@@ -392,5 +393,9 @@ func (a *Attacker) hit(tr Targeter, name string) *Result {
res.Error = r.Status
}

var hdr bytes.Buffer
r.Header.Write(&hdr)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error return value of r.Header.Write is not checked (from errcheck)

lib/results.go Outdated Show resolved Hide resolved
@@ -217,6 +254,15 @@ func NewCSVDecoder(r io.Reader) Decoder {

r.Method = rec[9]
r.URL = rec[10]
if len(rec) > 11 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we set FieldsPerRecord = 12, then this is always going to be true, or else an error would be returned by read.

FieldsPerRecord is the number of expected fields per record. If FieldsPerRecord is positive, Read requires each record to have the given number of fields.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing this in a follow up commit. Thanks for the contribution!

@tsenart tsenart merged commit 08f5eea into tsenart:master Feb 16, 2020
@tsenart tsenart mentioned this pull request Feb 16, 2020
tsenart added a commit that referenced this pull request Mar 24, 2020
This commit improves the performance of JSON encoding and decoding of
`Results`. Additionally, it fixes a regression introduced in #474 that
didn't produce valid JSON for HTTP headers. A test is added that
validates the JSON encoding matches the one produced by the
`encoding/json`.

```
name                            old time/op    new time/op    delta
ResultEncodings/json-encode-16     690ns ±12%     297ns ± 0%   -56.94%
(p=0.000 n=9+9)
ResultEncodings/json-decode-16    1.05µs ± 1%    0.03µs ± 1%   -97.47%
(p=0.000 n=10+8)

name                            old alloc/op   new alloc/op   delta
ResultEncodings/json-encode-16      804B ±87%        0B       -100.00%
(p=0.000 n=9+10)
ResultEncodings/json-decode-16      310B ± 0%        0B       -100.00%
(p=0.000 n=10+10)

name                            old allocs/op  new allocs/op  delta
ResultEncodings/json-encode-16      4.00 ± 0%      0.00       -100.00%
(p=0.000 n=10+10)
ResultEncodings/json-decode-16      4.00 ± 0%      0.00       -100.00%
(p=0.000 n=10+10)
```
tsenart added a commit that referenced this pull request Mar 24, 2020
* Add .idea to .gitignore

* results: Faster JSON encoding and decoding

This commit improves the performance of JSON encoding and decoding of
`Results`. Additionally, it fixes a regression introduced in #474 that
didn't produce valid JSON for HTTP headers. A test is added that
validates the JSON encoding matches the one produced by the
`encoding/json`.

```
name                            old time/op    new time/op    delta
ResultEncodings/json-encode-16     690ns ±12%     297ns ± 0%   -56.94%
(p=0.000 n=9+9)
ResultEncodings/json-decode-16    1.05µs ± 1%    0.03µs ± 1%   -97.47%
(p=0.000 n=10+8)

name                            old alloc/op   new alloc/op   delta
ResultEncodings/json-encode-16      804B ±87%        0B       -100.00%
(p=0.000 n=9+10)
ResultEncodings/json-decode-16      310B ± 0%        0B       -100.00%
(p=0.000 n=10+10)

name                            old allocs/op  new allocs/op  delta
ResultEncodings/json-encode-16      4.00 ± 0%      0.00       -100.00%
(p=0.000 n=10+10)
ResultEncodings/json-decode-16      4.00 ± 0%      0.00       -100.00%
(p=0.000 n=10+10)
```
olaiojo pushed a commit to olaiojo/vegeta that referenced this pull request Feb 15, 2022
olaiojo added a commit to olaiojo/vegeta that referenced this pull request Feb 15, 2022
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

Successfully merging this pull request may close these issues.

Capture HTTP response header in vegeta.Result
3 participants