-
Notifications
You must be signed in to change notification settings - Fork 741
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
Introduce currency support in adapters bid responses as described in #280. #491
Conversation
2d0daec
to
276ee4a
Compare
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 overall! A few little things did jump out at me... see below.
adapters/bidder.go
Outdated
// to "USD". | ||
// | ||
// By default, currency is USD but this behavior might be subject to change. | ||
func NewBidderResponse() *BidderResponse { |
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 allow an initial capacity here?
It seems like many of the adapters were using this and lost it. For example:
- bids := make([]*adapters.TypedBid, 0, len(adformBids))
+func toOpenRtbBidResponse(adformBids []*adformBid, r *openrtb.BidRequest) *adapters.BidderResponse {
+ bidResponse := adapters.NewBidderResponse()
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.
Fair point !
I let a default constructor NewBidderResponse()
and also added a NewBidderResponseWithBidsCapacity(bidsCapacity int)
and use the later in the adapters leveraging bids capacity earlier.
adapters/adapterstest/test_json.go
Outdated
bidsErrs = append(bidsErrs, theseErrs...) | ||
if thisBidResponse != nil { | ||
// The currency is the same accross all bids |
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.
hmm... I'm a little puzzled by this. I know everything is USD
now, but how do you plan to handle this in the live code?
As a Bidder, I would expect to be able to return different currencies for different calls to MakeBids
. Since HTTP calls are made in parallel, the behavior might not even be deterministic; HTTP Responses with different currencies might come back in different orders for different auctions.
I feel like this would be much less confusing as:
"expectedBidResponses": [
{
"currency": "USD",
"bids: [...]
},
{
"currency": "USD",
"bids": [...]
}
]
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.
Fair point, I agree with you, I make sure that currency is populated everytime:
if thisBidResponse != nil {
bidResponse.Currency = thisBidResponse.Currency
bidResponse.Bids = append(bidResponse.Bids, thisBidResponse.Bids...)
}
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.
wait... I'm a little bit confused by what this accomplishes.
I might be missing something... but it looks like the currency from the last call to MakeBids
takes effect now, rather than the first one.
This behavior still seems like it'd be confusing to Bidders, and still seems to have the same problem with determinism from the parallel calls in live code?
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 sorry, I get what you meant, just updated the change, let me know what you think.
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.
perfect :). Thanks!
bids[i].Bid.Price = bids[i].Bid.Price * bidAdjustment | ||
if bidResponse != nil { | ||
for i := 0; i < len(bidResponse.Bids); i++ { | ||
if bidResponse.Bids[i].Bid != nil { |
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.
Could you stick a // TODO #280: Convert the bid price
comment here? Just so we don't lose track of it.
A TODO #280
would also be useful in the `func (brw *bidResponseWrapper) validateBids().
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.
Yes good point, just done
071e2c6
to
f7347dc
Compare
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.
This is nice and clean plumbing and well limited in scope. The BidderResponse
container will make it easier in the future for adapters to pass additional information back to the exchange.
…nses as described in prebid#280. This change covers: * Introducing a new struct `BidderResponse` carrying the list of bids `TypedBid` and a currency as string * Change the existing adapters using the new API `MakeBids` so it start using the new `BidderResponse` struct This change doesn't cover: * Doesn't change the former API using `Call` method * Any check done on Pre-bid server side to discard any bid received with an invalid currency (such as unknown, or a one that wasn't authorized in a first place via trhe bid request) * Any mechanisms on tranlating currency rates As a nice next step, we should implement the mechanism to filter bids having invalid currencies on not allowed ones. It will allow to protect both parties from currencies mismatch / discrepancies.
f7347dc
to
0ad0d1b
Compare
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 great!
Thanks guys :) |
@dbemiller - would like to discuss the design here because PBS-Java is returning currency in a different way, so this is now a difference in how bid adapters would need to set currency in Go-vs-Java.
It isn't a requirement that each bid have a separate currency, but approach #2 has the nice property that the currency stays associated with each bid, so it's cached and analytics adapters may have easier access. Is it true that in the design #1 the currency doesn't survive the call to Prebid Cache? Unclear that's a near-term requirement, but seems like something that could be important should anyone want to look at the CPM again. |
Hey @bretg I wasn't aware of this behavior difference between Go / Java. Happy to try another solution if you guys want. But the |
@benjaminch - it's good encapsulation for sure. My concern is about what's cached -- if that common info isn't stored in PBC, we won't have it at render time. So of course an alternate solution is to change how such common info is cached. |
@bretg That idea was actually pitched here:
We settled on I'm very strongly opposed to asking a community member rewrite code based on differences between Go/Java. Forking projets has a very high maintenance cost, which is why Prebid.org isn't officially supporting the Java version. I'm a little confused by the more substantive objections, though. The Bidder API changes here don't affect the Analytics adapter APIs or what we cache. We can easily change both regardless of how Bidders return the info To me, it seems like the root question is:
If it's common, it should be inside The only way these PR changes are "bad" is if it's a common case. If we need to transition from Also worth noting: OpenRTB defines |
I wasn't asking for a change, I was asking to discuss the design. Hence the wording: "would like to discuss the design here". Sorry for not catching the design discussion in the other thread.
Never - this wasn't the issue.
Very well. I accept this. We'll change the Java version at some point. |
…nses as described in prebid#280. (prebid#491) This change covers: * Introducing a new struct `BidderResponse` carrying the list of bids `TypedBid` and a currency as string * Change the existing adapters using the new API `MakeBids` so it start using the new `BidderResponse` struct This change doesn't cover: * Doesn't change the former API using `Call` method * Any check done on Pre-bid server side to discard any bid received with an invalid currency (such as unknown, or a one that wasn't authorized in a first place via trhe bid request) * Any mechanisms on tranlating currency rates As a nice next step, we should implement the mechanism to filter bids having invalid currencies on not allowed ones. It will allow to protect both parties from currencies mismatch / discrepancies.
…nses as described in prebid#280. (prebid#491) This change covers: * Introducing a new struct `BidderResponse` carrying the list of bids `TypedBid` and a currency as string * Change the existing adapters using the new API `MakeBids` so it start using the new `BidderResponse` struct This change doesn't cover: * Doesn't change the former API using `Call` method * Any check done on Pre-bid server side to discard any bid received with an invalid currency (such as unknown, or a one that wasn't authorized in a first place via trhe bid request) * Any mechanisms on tranlating currency rates As a nice next step, we should implement the mechanism to filter bids having invalid currencies on not allowed ones. It will allow to protect both parties from currencies mismatch / discrepancies.
…nses as described in prebid#280. (prebid#491) This change covers: * Introducing a new struct `BidderResponse` carrying the list of bids `TypedBid` and a currency as string * Change the existing adapters using the new API `MakeBids` so it start using the new `BidderResponse` struct This change doesn't cover: * Doesn't change the former API using `Call` method * Any check done on Pre-bid server side to discard any bid received with an invalid currency (such as unknown, or a one that wasn't authorized in a first place via trhe bid request) * Any mechanisms on tranlating currency rates As a nice next step, we should implement the mechanism to filter bids having invalid currencies on not allowed ones. It will allow to protect both parties from currencies mismatch / discrepancies.
* OTT-1058: record number of deal responses for given pub-prof-partner (prebid#485) (prebid#487) Co-authored-by: Pubmatic-Dhruv-Sonone <[email protected]> * OTT-1060: Added IncDealBidCount in stats server for selected publishe… (prebid#491) --------- Co-authored-by: ashishshinde-pubm <[email protected]> Co-authored-by: Pubmatic-Dhruv-Sonone <[email protected]> Co-authored-by: ShriprasadM <[email protected]>
This CL introduces currency declaration support in adapters bid responses as described in #280.
This change covers:
BidderResponse
carrying the list of bidsTypedBid
and a currency as stringMakeBids
so it start using the newBidderResponse
structThis change doesn't cover:
Call
method(such as unknown, or a one that wasn't authorized in a first place via trhe bid request)
As a nice next step, we should implement the mechanism to filter bids having invalid currencies on not allowed ones.
It will allow to protect both parties from currencies mismatch / discrepancies.