-
Notifications
You must be signed in to change notification settings - Fork 760
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
Pass Host Config Info to Bid Adapters #2370
Conversation
adapters/33across/33across.go
Outdated
@@ -15,6 +15,7 @@ import ( | |||
|
|||
type TtxAdapter struct { | |||
endpoint string | |||
Server config.Server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not going to like this after already completing the work, but I recommend not to add the server variable to the adapter structs. Let's leave it to adapters to capture that information in the future if they'd like. For now, I think we're good with just the updates to the Builder methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I've got the muscle memory down for updating the adapters! I'll remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂
openrtb_ext/request.go
Outdated
@@ -57,7 +57,8 @@ type ExtRequestPrebid struct { | |||
// NoSale specifies bidders with whom the publisher has a legal relationship where the | |||
// passing of personally identifiable information doesn't constitute a sale per CCPA law. | |||
// The array may contain a single sstar ('*') entry to represent all bidders. | |||
NoSale []string `json:"nosale,omitempty"` | |||
NoSale []string `json:"nosale,omitempty"` | |||
Server *ExtRequestPrebidServer `json:"server,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this alphabetically in the above section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you for the updates. I noticed two more things in this review pas.
exchange/adapter_util.go
Outdated
@@ -26,7 +27,7 @@ func BuildAdapters(client *http.Client, cfg *config.Configuration, infos config. | |||
return exchangeBidders, nil | |||
} | |||
|
|||
func buildBidders(adapterConfig map[string]config.Adapter, infos config.BidderInfos, builders map[openrtb_ext.BidderName]adapters.Builder) (map[openrtb_ext.BidderName]adapters.Bidder, []error) { | |||
func buildBidders(adapterConfig map[string]config.Adapter, infos config.BidderInfos, builders map[openrtb_ext.BidderName]adapters.Builder, hostInfo config.Server) (map[openrtb_ext.BidderName]adapters.Bidder, []error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend to rename hostInfo
to server
to match the name in the Builder definition and to consider keeping the builders argument as the last one in the signature.
config/config.go
Outdated
@@ -597,6 +598,12 @@ type Debug struct { | |||
OverrideToken string `mapstructure:"override_token"` | |||
} | |||
|
|||
type Server struct { | |||
ExternalUrl string `mapstructure:"external_url"` | |||
GdprID int `mapstructure:"gdpr_id"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Can we change this name to indicate it is a GVL ID or the GDPR host vendor ID so it is more indicative of what it represents? This data structure appears to be internal to PBS so it should be ok to deviate from what is described in the issue.
openrtb_ext/request.go
Outdated
@@ -108,6 +109,12 @@ type ExtRequestPrebidCache struct { | |||
VastXML *ExtRequestPrebidCacheVAST `json:"vastxml"` | |||
} | |||
|
|||
type ExtRequestPrebidServer struct { | |||
ExternalUrl string `json:"externalurl"` | |||
GdprID string `json:"gvlid"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this something else like GVLID
, HostGVLID
or GDPRHostVendorID
instead of GdprID
to more accurately reflect what this is? I see this is referred to as Gdpr ID in the issue but changing this variable name shouldn't have any external effect since the name of the field on a request is gvlid
and the config value is gdpr.host_vendor_id
.
exchange/exchange.go
Outdated
@@ -202,6 +204,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog * | |||
if err != nil { | |||
return nil, err | |||
} | |||
requestExt.Prebid.Server = &openrtb_ext.ExtRequestPrebidServer{ExternalUrl: e.server.ExternalUrl, GvlID: e.server.GvlID, Datacenter: e.server.Datacenter} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we only be setting this if we have at least one piece of server data? Otherwise we end up with an empty prebid.server
object in our bid requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good idea. An Empty
method on ExtRequestPrebidServer
might be nice to check for this condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good check to add! Will update
config/config.go
Outdated
@@ -95,7 +95,7 @@ type Configuration struct { | |||
HostSChainNode *openrtb2.SupplyChainNode `mapstructure:"host_schain_node"` | |||
// Experiment configures non-production ready features. | |||
Experiment Experiment `mapstructure:"experiment"` | |||
|
|||
Datacenter string `mapstructure:"datacenter"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Consider changing name to DataCenter
. The Viper name and mapstructure should stay as is.
config/config.go
Outdated
type Server struct { | ||
ExternalUrl string `mapstructure:"external_url"` | ||
GvlID int `mapstructure:"gvlid"` | ||
Datacenter string `mapstructure:"datacenter"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Consider changing name to DataCenter
. You can use the rename functionality in your editor to do this easily.
config/config.go
Outdated
type Server struct { | ||
ExternalUrl string `mapstructure:"external_url"` | ||
GvlID int `mapstructure:"gvlid"` | ||
Datacenter string `mapstructure:"datacenter"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Please remove the mapstructure attributes. Those are for viper and we're not using viper here.
config/config.go
Outdated
@@ -729,7 +735,7 @@ func (cfg *Configuration) AccountDefaultsJSON() json.RawMessage { | |||
return cfg.accountDefaultsJSON | |||
} | |||
|
|||
//Allows for protocol relative URL if scheme is empty | |||
// Allows for protocol relative URL if scheme is empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nipick: If you're going to fix the comment, please change it to start with the function name, ie
// GetBaseURL allows for...
openrtb_ext/request.go
Outdated
type ExtRequestPrebidServer struct { | ||
ExternalUrl string `json:"externalurl"` | ||
GvlID int `json:"gvlid"` | ||
Datacenter string `json:"datacenter"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Consider changing field name to DataCenter
.
exchange/exchange.go
Outdated
if requestExt.Prebid.Server.Empty() { | ||
requestExt.Prebid.Server = &openrtb_ext.ExtRequestPrebidServer{ExternalUrl: e.server.ExternalUrl, GvlID: e.server.GvlID, DataCenter: e.server.DataCenter} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah my earlier thought here wasn't about checking if there was any server data specified in the request, but rather about checking if there was any host data so that we only set requestExt.Prebid.Server
if e.server
is non-empty in order to avoid creating an object at ext.prebid.server
without any real data in it.
My understanding is that server info specified in the host config should always overwrite what is specified in the request.
@SyntaxNode, your suggestion was that it might make sense to put an Empty
method on ExtRequestPrebidServer
. Were you thinking the logic would then be something like this?
serverInfo := openrtb_ext.ExtRequestPrebidServer{ExternalUrl: e.server.ExternalUrl, GvlID: e.server.GvlID, DataCenter: e.server.DataCenter}
if !extPrebidServer.Empty() {
requestExt.Prebid.Server = &serverInfo
}
Or should the Empty
method go on type Server
defined in config/config.go
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, I think I messed this up! I think you're right in saying we should only set requestExt.Prebid.Server
here when e.server
is non-empty. And I could add an Empty
method to check if e.server
is non-empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but need confirmation from @SyntaxNode regarding handling an empty host config.
@@ -2369,74 +2369,28 @@ func TestBuildRequestExtForBidder(t *testing.T) { | |||
expectedJson: json.RawMessage(`{"prebid":{}}`), | |||
}, | |||
{ | |||
description: "Prebid - Allowed Fields Only", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might have made a mistake when merging with master. The test cases in this test shouldn't have been deleted or modified to remove references to the test input alternateBidderCodes
.
I think you might want to just augment some of these test cases by adding references to request.ext.prebid.server
. Actually I think you had done this but lost it during the merge.
This PR addresses this issue: #1739
The goal of the PR is to pass specific host info to bid adapters in two different ways
This host info data we want passed consists of:
externalUrl
,gvlID
, anddatacenter
One way is to pass this info in the auction request itself at the path
ext.prebid.server
(i.e.ext.prebid.server.datacenter
)The second way is to pass this info as a configuration data structure
When it comes to adding the info to the auction request, all bid adapters get a copy of the request, so as long as I properly update the request to include these new values (and ensure they don't get cleaned), this should suffice in accomplishing the first way of passing the info.
To do this, what I needed was to create a new request object in
openrtb_ext/request.go
calledExtRequestPrebidServer
, which will hold the three host info values we want to support. This object is then added as another parameter of theExtRequestPrebid
object.To ensure the new host info wouldn't be scrubbed from the request that's sent to bid adapters, I had to update
cleanOpenRTBRequests()
-->buildRequestExtForBidder()
and add the new host info Server object to theExtRequestPrebid
object that's being built there.When it comes to passing this info as config data structure, I created a new data structure in
config.go
calledServer
which holds the three host info values, and that object is added to theConfiguration
object. And then I updatedSetupViper()
so that the host could set the values of this object.In order for this config object to be available to adapters, I had to update the
Builder()
function that all adapters use to build a new instance of their adapter. Simply, theBuilder()
function is updated to accept the configServer
object (which is taken from theServer
object defined byViper
), and thatServer
object is then added to that particular adapter object.This change had to be applied to all adapters, and all adapters tests, so that's where the bulk of the files changed comes from.