Skip to content

Commit b69911b

Browse files
authored
Revert "msb peek version (#59)" (#82)
This reverts commit 798a249.
1 parent fcf5706 commit b69911b

File tree

3 files changed

+71
-282
lines changed

3 files changed

+71
-282
lines changed

endpoints/openrtb2/auction.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9+
"github.com/prebid/prebid-server/privacy"
910
"io"
1011
"io/ioutil"
1112
"net/http"
@@ -15,8 +16,6 @@ import (
1516
"strings"
1617
"time"
1718

18-
"github.com/prebid/prebid-server/privacy"
19-
2019
"github.com/buger/jsonparser"
2120
"github.com/gofrs/uuid"
2221
"github.com/golang/glog"
@@ -205,13 +204,6 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http
205204
ctx := context.Background()
206205

207206
timeout := deps.cfg.AuctionTimeouts.LimitAuctionTimeout(time.Duration(req.TMax) * time.Millisecond)
208-
209-
// adjust tmax for requests with MSB feature enabled
210-
msbConfig := exchange.ExtractMSBInfoReq(req.BidRequest)
211-
if msbConfig.LastPeek.PeekStartTimeMilliSeconds > 0 {
212-
timeout += time.Duration(msbConfig.LastPeek.PeekStartTimeMilliSeconds) * time.Millisecond
213-
}
214-
215207
if timeout > 0 {
216208
var cancel context.CancelFunc
217209
ctx, cancel = context.WithDeadline(ctx, start.Add(timeout))

exchange/exchange.go

Lines changed: 70 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9+
"github.com/prebid/prebid-server/privacy"
910
"math/rand"
1011
"net/url"
1112
"runtime/debug"
@@ -14,11 +15,6 @@ import (
1415
"strings"
1516
"time"
1617

17-
"github.com/buger/jsonparser"
18-
uuid "github.com/gofrs/uuid"
19-
"github.com/golang/glog"
20-
"github.com/prebid/openrtb/v19/openrtb2"
21-
"github.com/prebid/openrtb/v19/openrtb3"
2218
"github.com/prebid/prebid-server/adapters"
2319
"github.com/prebid/prebid-server/adservertargeting"
2420
"github.com/prebid/prebid-server/bidadjustment"
@@ -35,11 +31,16 @@ import (
3531
"github.com/prebid/prebid-server/metrics"
3632
"github.com/prebid/prebid-server/openrtb_ext"
3733
"github.com/prebid/prebid-server/prebid_cache_client"
38-
"github.com/prebid/prebid-server/privacy"
3934
"github.com/prebid/prebid-server/stored_requests"
4035
"github.com/prebid/prebid-server/stored_responses"
4136
"github.com/prebid/prebid-server/usersync"
4237
"github.com/prebid/prebid-server/util/maputil"
38+
39+
"github.com/buger/jsonparser"
40+
"github.com/gofrs/uuid"
41+
"github.com/golang/glog"
42+
"github.com/prebid/openrtb/v19/openrtb2"
43+
"github.com/prebid/openrtb/v19/openrtb3"
4344
)
4445

4546
type extCacheInstructions struct {
@@ -655,86 +656,6 @@ func (e *exchange) makeAuctionContext(ctx context.Context, needsCache bool) (auc
655656
return
656657
}
657658

658-
func (e *exchange) processBidder(
659-
ctx context.Context,
660-
bidderRequests []BidderRequest,
661-
bidAdjustments map[string]float64,
662-
conversions currency.Conversions,
663-
accountDebugAllowed bool,
664-
globalPrivacyControlHeader string,
665-
headerDebugAllowed bool,
666-
alternateBidderCodes openrtb_ext.ExtAlternateBidderCodes,
667-
experiment *openrtb_ext.Experiment,
668-
hookExecutor hookexecution.StageExecutor,
669-
bidAdjustmentRules map[string][]openrtb_ext.Adjustment,
670-
chBids chan *bidResponseWrapper,
671-
bidder BidderRequest) {
672-
// Here we actually call the adapters and collect the bids.
673-
bidderRunner := e.recoverSafely(bidderRequests, func(bidderRequest BidderRequest, conversions currency.Conversions) {
674-
// Passing in aName so a doesn't change out from under the go routine
675-
if bidderRequest.BidderLabels.Adapter == "" {
676-
glog.Errorf("Exchange: bidlables for %s (%s) missing adapter string", bidderRequest.BidderName, bidderRequest.BidderCoreName)
677-
bidderRequest.BidderLabels.Adapter = bidderRequest.BidderCoreName
678-
}
679-
brw := new(bidResponseWrapper)
680-
brw.bidder = bidderRequest.BidderName
681-
brw.adapter = bidderRequest.BidderCoreName
682-
// Defer basic metrics to insure we capture them after all the values have been set
683-
defer func() {
684-
e.me.RecordAdapterRequest(bidderRequest.BidderLabels)
685-
}()
686-
start := time.Now()
687-
688-
reqInfo := adapters.NewExtraRequestInfo(conversions)
689-
reqInfo.PbsEntryPoint = bidderRequest.BidderLabels.RType
690-
reqInfo.GlobalPrivacyControlHeader = globalPrivacyControlHeader
691-
reqInfo.BidderRequestStartTime = start
692-
693-
bidReqOptions := bidRequestOptions{
694-
accountDebugAllowed: accountDebugAllowed,
695-
headerDebugAllowed: headerDebugAllowed,
696-
addCallSignHeader: isAdsCertEnabled(experiment, e.bidderInfo[string(bidderRequest.BidderName)]),
697-
bidAdjustments: bidAdjustments,
698-
}
699-
700-
seatBids, err := e.adapterMap[bidderRequest.BidderCoreName].requestBid(ctx, bidderRequest, conversions, &reqInfo, e.adsCertSigner, bidReqOptions, alternateBidderCodes, hookExecutor, bidAdjustmentRules)
701-
702-
// Add in time reporting
703-
elapsed := time.Since(start)
704-
brw.adapterSeatBids = seatBids
705-
// Structure to record extra tracking data generated during bidding
706-
ae := new(seatResponseExtra)
707-
ae.ResponseTimeMillis = int(elapsed / time.Millisecond)
708-
if len(seatBids) != 0 {
709-
ae.HttpCalls = seatBids[0].HttpCalls
710-
}
711-
// SeatBidsPreparationStartTime is needed to calculate duration for openrtb response preparation time metric
712-
// No metric needs to be logged for requests which error out
713-
if err == nil {
714-
ae.MakeBidsTimeInfo = reqInfo.MakeBidsTimeInfo
715-
}
716-
// Timing statistics
717-
e.me.RecordAdapterTime(bidderRequest.BidderLabels, elapsed)
718-
bidderRequest.BidderLabels.AdapterBids = bidsToMetric(brw.adapterSeatBids)
719-
bidderRequest.BidderLabels.AdapterErrors = errorsToMetric(err)
720-
// Append any bid validation errors to the error list
721-
ae.Errors = errsToBidderErrors(err)
722-
ae.Warnings = errsToBidderWarnings(err)
723-
brw.adapterExtra = ae
724-
for _, seatBid := range seatBids {
725-
if seatBid != nil {
726-
for _, bid := range seatBid.Bids {
727-
var cpm = float64(bid.Bid.Price * 1000)
728-
e.me.RecordAdapterPrice(bidderRequest.BidderLabels, cpm)
729-
e.me.RecordAdapterBidReceived(bidderRequest.BidderLabels, bid.BidType, bid.Bid.AdM != "")
730-
}
731-
}
732-
}
733-
chBids <- brw
734-
}, chBids)
735-
go bidderRunner(bidder, conversions)
736-
}
737-
738659
// This piece sends all the requests to the bidder adapters and gathers the results.
739660
func (e *exchange) getAllBids(
740661
ctx context.Context,
@@ -760,30 +681,71 @@ func (e *exchange) getAllBids(
760681
bidsFound := false
761682

762683
e.me.RecordOverheadTime(metrics.MakeBidderRequests, time.Since(pbsRequestStartTime))
763-
lastPeekBidderRequests := []BidderRequest{}
764-
msbConfig := extractMSBInfoBidders(bidderRequests)
765684

766685
for _, bidder := range bidderRequests {
767-
// save 2nd - nth peek tier bidder requests and process later
768-
// if needed add in the future
769-
770-
// save last peek bidder requests and process later
771-
bidderName := bidder.BidderName.String()
772-
if _, isLastPeekBidder := msbConfig.LastPeek.PeekBidderFloorMultMap[bidderName]; isLastPeekBidder {
773-
lastPeekBidderRequests = append(lastPeekBidderRequests, bidder)
774-
continue
775-
}
776-
e.processBidder(ctx, bidderRequests, bidAdjustments, conversions, accountDebugAllowed, globalPrivacyControlHeader, headerDebugAllowed, alternateBidderCodes, experiment, hookExecutor, bidAdjustmentRules, chBids, bidder)
777-
}
778-
779-
// process msb 2nd - nth peek tier bidder request:
780-
// if needed add in the future
781-
782-
// process msb last peek bidder requests:
783-
if len(lastPeekBidderRequests) > 0 {
784-
for _, bidder := range mspUpdateLastPeekBiddersRequest(chBids, lastPeekBidderRequests, msbConfig.LastPeek, len(bidderRequests)-len(lastPeekBidderRequests)) {
785-
e.processBidder(ctx, bidderRequests, bidAdjustments, conversions, accountDebugAllowed, globalPrivacyControlHeader, headerDebugAllowed, alternateBidderCodes, experiment, hookExecutor, bidAdjustmentRules, chBids, bidder)
786-
}
686+
// Here we actually call the adapters and collect the bids.
687+
bidderRunner := e.recoverSafely(bidderRequests, func(bidderRequest BidderRequest, conversions currency.Conversions) {
688+
// Passing in aName so a doesn't change out from under the go routine
689+
if bidderRequest.BidderLabels.Adapter == "" {
690+
glog.Errorf("Exchange: bidlables for %s (%s) missing adapter string", bidderRequest.BidderName, bidderRequest.BidderCoreName)
691+
bidderRequest.BidderLabels.Adapter = bidderRequest.BidderCoreName
692+
}
693+
brw := new(bidResponseWrapper)
694+
brw.bidder = bidderRequest.BidderName
695+
brw.adapter = bidderRequest.BidderCoreName
696+
// Defer basic metrics to insure we capture them after all the values have been set
697+
defer func() {
698+
e.me.RecordAdapterRequest(bidderRequest.BidderLabels)
699+
}()
700+
start := time.Now()
701+
702+
reqInfo := adapters.NewExtraRequestInfo(conversions)
703+
reqInfo.PbsEntryPoint = bidderRequest.BidderLabels.RType
704+
reqInfo.GlobalPrivacyControlHeader = globalPrivacyControlHeader
705+
reqInfo.BidderRequestStartTime = start
706+
707+
bidReqOptions := bidRequestOptions{
708+
accountDebugAllowed: accountDebugAllowed,
709+
headerDebugAllowed: headerDebugAllowed,
710+
addCallSignHeader: isAdsCertEnabled(experiment, e.bidderInfo[string(bidderRequest.BidderName)]),
711+
bidAdjustments: bidAdjustments,
712+
}
713+
seatBids, err := e.adapterMap[bidderRequest.BidderCoreName].requestBid(ctx, bidderRequest, conversions, &reqInfo, e.adsCertSigner, bidReqOptions, alternateBidderCodes, hookExecutor, bidAdjustmentRules)
714+
715+
// Add in time reporting
716+
elapsed := time.Since(start)
717+
brw.adapterSeatBids = seatBids
718+
// Structure to record extra tracking data generated during bidding
719+
ae := new(seatResponseExtra)
720+
ae.ResponseTimeMillis = int(elapsed / time.Millisecond)
721+
if len(seatBids) != 0 {
722+
ae.HttpCalls = seatBids[0].HttpCalls
723+
}
724+
// SeatBidsPreparationStartTime is needed to calculate duration for openrtb response preparation time metric
725+
// No metric needs to be logged for requests which error out
726+
if err == nil {
727+
ae.MakeBidsTimeInfo = reqInfo.MakeBidsTimeInfo
728+
}
729+
// Timing statistics
730+
e.me.RecordAdapterTime(bidderRequest.BidderLabels, elapsed)
731+
bidderRequest.BidderLabels.AdapterBids = bidsToMetric(brw.adapterSeatBids)
732+
bidderRequest.BidderLabels.AdapterErrors = errorsToMetric(err)
733+
// Append any bid validation errors to the error list
734+
ae.Errors = errsToBidderErrors(err)
735+
ae.Warnings = errsToBidderWarnings(err)
736+
brw.adapterExtra = ae
737+
for _, seatBid := range seatBids {
738+
if seatBid != nil {
739+
for _, bid := range seatBid.Bids {
740+
var cpm = float64(bid.Bid.Price * 1000)
741+
e.me.RecordAdapterPrice(bidderRequest.BidderLabels, cpm)
742+
e.me.RecordAdapterBidReceived(bidderRequest.BidderLabels, bid.BidType, bid.Bid.AdM != "")
743+
}
744+
}
745+
}
746+
chBids <- brw
747+
}, chBids)
748+
go bidderRunner(bidder, conversions)
787749
}
788750
var fledge *openrtb_ext.Fledge
789751

0 commit comments

Comments
 (0)