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

requestheaders: new parameter inside debug.httpcalls.<BIDDER> to log request header details #1659

Merged
merged 4 commits into from
Jan 28, 2021

Conversation

ShriprasadM
Copy link
Contributor

@ShriprasadM ShriprasadM commented Jan 20, 2021

httpcalls.<BIDDER>.requestheaders - New Debug parameter

@SyntaxNode, Please review and approve this PR.

It will be useful to log a set of request headers sent to the actual Bidder. This will help in verifying if required request headers are correctly getting sent to the actual Bidder.

This parameter will be visible only when query parameter debug=1 is set. For example,

http://localhost:8000/openrtb2/video?debug=1
image

In above example requestheaders indicating 2 headers are sent to appnexus bidder.

  1. "Accept": ["application/json"],
  2. "Content-Type": ["application/json;charset=utf-8"]

RequestBody: string(httpInfo.request.Body),
Uri: httpInfo.request.Uri,
RequestBody: string(httpInfo.request.Body),
RequestHeaders: httpInfo.request.Headers,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Log Request Headers when there is error

exchange/bidder_test.go Outdated Show resolved Hide resolved
@@ -910,6 +916,7 @@ func TestBadResponseLogging(t *testing.T) {
if ext.Status != 0 {
t.Errorf("The Status code should be 0. Got %d", ext.Status)
}
assert.Equal(t, info.request.Headers, http.Header(ext.RequestHeaders), "The request headers should be \"header-1:value-1\"")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Verify Request headers are logged when there is a bad response

Comment on lines +900 to +902
Headers: http.Header{
"header-1": []string{"value-1"},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simulation of request headers set

Comment on lines +928 to +930
Headers: http.Header{
"header-1": []string{"value-1", "value-2"},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simulation of request headers set

@@ -937,6 +947,7 @@ func TestSuccessfulResponseLogging(t *testing.T) {
if ext.Status != info.response.StatusCode {
t.Errorf("The Status code should be 0. Got %d", ext.Status)
}
assert.Equal(t, info.request.Headers, http.Header(ext.RequestHeaders), "The request headers should be \"%s\". Got %s", info.request.Headers, ext.RequestHeaders)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Verify Request headers are logged when there is a bad response

@@ -65,6 +65,7 @@
{
"uri": "appnexusTest.com",
"requestbody": "appnexusTestRequestBody",
"requestheaders": null,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added new parameter to satisfy the unit test

@@ -150,15 +152,17 @@
"uri": "appnexusTest.com",
"requestbody": "appnexusTestRequestBody",
"responsebody": "appnexusTestResponseBody",
"status": 200
"status": 200,
"requestheaders": null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added new parameter to satisfy the unit test

}
],
"audienceNetwork": [
{
"uri": "audienceNetworkTest.com",
"requestbody": "audienceNetworkTestRequestBody",
"responsebody": "audienceNetworkTestResponseBody",
"status": 200
"status": 200,
"requestheaders": null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added new parameter to satisfy the unit test

RequestBody string `json:"requestbody"`
ResponseBody string `json:"responsebody"`
Status int `json:"status"`
RequestHeaders map[string][]string `json:"requestheaders"`
Copy link
Contributor Author

@ShriprasadM ShriprasadM Jan 20, 2021

Choose a reason for hiding this comment

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

The new parameter RequestHeaders will contain the header key and multiple values associated with it.
We have kept value as an array of strings because one header can have multiple values.
Also, this data structure is inline with http/Header
requestheaders is the key used while forming the JSON

@ShriprasadM ShriprasadM marked this pull request as ready for review January 20, 2021 14:02
@ShriprasadM
Copy link
Contributor Author

@SyntaxNode : Please review and merge

@SyntaxNode
Copy link
Contributor

@SyntaxNode : Please review and merge

It's in our queue to review early next week.

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

Looks pretty good. Could we create an additional JSON test where "requestheaders" is not null? Say a file probably named exchange/exchangetest/request-debug-info-with-headers.json where we can assert that the request headers where correctly marshalled into the response.

…der information.

Modified sample mock response such that ext.debug.httpcalls.appnexus.requestheaders will return the information of passed request headers
hhhjort
hhhjort previously approved these changes Jan 26, 2021
Copy link
Collaborator

@hhhjort hhhjort left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

Looks pretty good @ShriprasadM . I believe the only thing pending is @SyntaxNode 's comment on exchange/bidder_test.go line 889

exchange/bidder_test.go Outdated Show resolved Hide resolved
Also Moved RequestHeaders next to RequestBidy in openrtb_ext.ExtHttpCall
@ShriprasadM
Copy link
Contributor Author

ShriprasadM commented Jan 27, 2021

@SyntaxNode : I have addressed the review comment
@guscarreon and @SyntaxNode : Please review and merge

I have also moved Requestheaders declaration next to RequestBody. Here is the diff - 0217a04#diff-3c1ac989dd21a327ea120cbd84a4d7484528ba9be45903abac53efb283a3f115

Do we need any documentation update around it ?

@hhhjort : Thanks for review

Status int `json:"status"`
Uri string `json:"uri"`
RequestBody string `json:"requestbody"`
RequestHeaders map[string][]string `json:"requestheaders"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved RequestHeaders next to RequestBody

@ShriprasadM
Copy link
Contributor Author

@SyntaxNode : Can you review and approve?

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@hhhjort hhhjort left a comment

Choose a reason for hiding this comment

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

LGTM

@hhhjort hhhjort merged commit 3793d4c into prebid:master Jan 28, 2021
@ShriprasadM
Copy link
Contributor Author

Thanks @SyntaxNode , @guscarreon and @hhhjort

Do we need any documentation update around it ?

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.

5 participants