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

OTT-1168: support for traffic shaping based on country code #794

Merged
merged 41 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0235e1e
OTT-1450: add support of Netacuity geoDB for ip-to-geo lookup (#663)
ashishshinde-pubm Dec 18, 2023
de0c4d8
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into …
ashishshinde-pubm Dec 27, 2023
1361bda
OTT-1449: Traffic Shapping Framework (#671)
Pubmatic-Dhruv-Sonone Dec 27, 2023
cf2c4f5
OTT-908: Add support to get country from IP address (#679)
Ankit-Pinge Jan 5, 2024
efc892d
OTT-1450: Introduce ignoreNetacuity build flag in validate.sh (#682)
ashishshinde-pubm Jan 18, 2024
0050587
Merge branch 'ci' of https://github.com/PubMatic-OpenWrap/prebid-serv…
Ankit-Pinge Feb 5, 2024
8ebc941
UT fix
Ankit-Pinge Feb 5, 2024
53cf3a2
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into …
ashishshinde-pubm Feb 26, 2024
aea8143
OTT-1448: Log seatnonbid rejected due to filtered bidders (#699)
Ankit-Pinge Feb 27, 2024
07f21f5
Merge branch 'ci' of https://github.com/PubMatic-OpenWrap/prebid-serv…
ashishshinde-pubm May 14, 2024
58aab0b
fix merge issues
ashishshinde-pubm May 15, 2024
7596c4d
Fix adapterCode issue
ashishshinde-pubm May 15, 2024
0eb1199
revert gitignore
ashishshinde-pubm May 15, 2024
72a7004
add seatnonbids in responseExt for CTV endpoints
ashishshinde-pubm May 15, 2024
1840dd6
Merge branch 'OTT-1168' of https://github.com/PubMatic-OpenWrap/prebi…
ashishshinde-pubm May 15, 2024
d5fa061
address nitpicks
ashishshinde-pubm May 15, 2024
dcbf0b2
fix debug.adpod missing in CTV request
ashishshinde-pubm May 16, 2024
c05b6ad
fix randomly failing UT
ashishshinde-pubm May 16, 2024
0e61eed
remove traffic shaping changes
pm-nilesh-chate May 17, 2024
9653177
remove used files
pm-nilesh-chate May 17, 2024
19deb0a
traffic shaping changes
pm-nilesh-chate May 17, 2024
5904dcf
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into …
ashishshinde-pubm May 17, 2024
abb1941
remove unwanted files
ashishshinde-pubm May 17, 2024
a4efe3d
remove unwanted files
ashishshinde-pubm May 17, 2024
685b5e0
Merge branch 'OTT-1168-traffic-shaping' of github.com:PubMatic-OpenWr…
ashishshinde-pubm May 17, 2024
a0b457b
Traffic Shaping Refactor
Pubmatic-Dhruv-Sonone May 20, 2024
229e0d6
OTT-1168: Traffic shaping refactor
Pubmatic-Dhruv-Sonone May 22, 2024
3561a96
Updating Adunit config
Pubmatic-Dhruv-Sonone May 22, 2024
221204a
Adding UTs
Pubmatic-Dhruv-Sonone May 22, 2024
2e9bd99
Merging latest ci
Pubmatic-Dhruv-Sonone May 22, 2024
9ba901e
Removed unused constant
Pubmatic-Dhruv-Sonone May 22, 2024
87dcd4f
Removing geodb from request context
Pubmatic-Dhruv-Sonone May 22, 2024
32b58f7
Reverting adunit changes
Pubmatic-Dhruv-Sonone May 22, 2024
e52b46f
do not start service if fail to load geodb
ashishshinde-pubm May 22, 2024
937e406
Merge branch 'OTT-1168-traffic-shaping' of github.com:PubMatic-OpenWr…
ashishshinde-pubm May 22, 2024
b88a455
Pulling latest code .
Pubmatic-Dhruv-Sonone May 24, 2024
6c8a22b
Fixing Init Reloader UT
Pubmatic-Dhruv-Sonone May 24, 2024
5809c8f
Fixing adunit unmarshalling issue
Pubmatic-Dhruv-Sonone May 27, 2024
56331b3
Ignoring bidderFilter in partnerConfig for appnexus params
Pubmatic-Dhruv-Sonone May 27, 2024
4a412e2
Removing redundant function params
Pubmatic-Dhruv-Sonone Jun 4, 2024
16db843
Adding Dummy Instance of Netacuity
Pubmatic-Dhruv-Sonone Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ analytics/filesystem/testFiles/
*.swp
*.swo
pbsimage
manual_build
manual_build
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ all: deps test build-modules build
# deps will clean out the vendor directory and use go mod for a fresh install
deps:
GOPROXY="https://proxy.golang.org" go mod vendor -v && go mod tidy -v

# test will ensure that all of our dependencies are available and run validate.sh
test: deps
# If there is no indentation, Make will treat it as a directive for itself; otherwise, it's regarded as a shell script.
Expand Down Expand Up @@ -37,10 +37,10 @@ format:
# formatcheck runs format for diagnostics, without modifying the code
formatcheck:
./scripts/format.sh -f false

mockgen: mockgeninstall mockgendb mockgencache mockgenmetrics mockgenlogger mockgenpublisherfeature

# export GOPATH=~/go ; GOBIN=~/go/bin; export PATH=$PATH:$GOBIN
# export GOPATH=~/go ; GOBIN=~/go/bin; export PATH=$PATH:$GOBIN
mockgeninstall:
go install github.com/golang/mock/[email protected]

Expand All @@ -57,6 +57,10 @@ mockgenmetrics:
mkdir -p modules/pubmatic/openwrap/metrics/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/metrics MetricsEngine > modules/pubmatic/openwrap/metrics/mock/mock.go

mockgengeodb:
mkdir -p modules/pubmatic/openwrap/geodb/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/geodb Geography > modules/pubmatic/openwrap/geodb/mock/mock.go

mockgenlogger:
mkdir -p analytics/pubmatic/mhttp/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/analytics/pubmatic/mhttp HttpCallInterface,MultiHttpContextInterface > analytics/pubmatic/mhttp/mock/mock.go
Expand Down
12 changes: 12 additions & 0 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/prebid/prebid-server/v2/hooks/hookexecution"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/customdimensions"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/models"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/models/nbr"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/utils"
"github.com/prebid/prebid-server/v2/openrtb_ext"
uuid "github.com/satori/go.uuid"
Expand All @@ -30,6 +31,11 @@ var GetUUID = func() string {
return uuid.NewV4().String()
}

var blockListedNBR = map[openrtb3.NoBidReason]struct{}{
nbr.RequestBlockedPartnerThrottle: {},
nbr.RequestBlockedPartnerFiltered: {},
}

// GetLogAuctionObjectAsURL will form the owlogger-url and http-headers
func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, rCtx *models.RequestCtx, logInfo, forRespExt bool) (string, http.Header) {
if ao.RequestWrapper == nil || ao.RequestWrapper.BidRequest == nil || rCtx == nil || rCtx.PubID == 0 || rCtx.LoggerDisabled {
Expand Down Expand Up @@ -395,6 +401,12 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
nbr = bidExt.Nbr // valid-bids + default-bids + dropped-bids
}

if nbr != nil {
if _, ok := blockListedNBR[*nbr]; ok {
continue
}
}

pr := PartnerRecord{
PartnerID: partnerID, // prebid biddercode
BidderCode: seat, // pubmatic biddercode: pubmatic2
Expand Down
86 changes: 45 additions & 41 deletions analytics/pubmatic/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/openrtb/v20/openrtb3"
"github.com/prebid/prebid-server/v2/analytics"
"github.com/prebid/prebid-server/v2/exchange"
"github.com/prebid/prebid-server/v2/hooks/hookanalytics"
Expand Down Expand Up @@ -114,9 +115,9 @@ func TestConvertNonBidToBid(t *testing.T) {
nonBid: openrtb_ext.NonBid{
StatusCode: int(exchange.ResponseRejectedBelowFloor),
ImpId: "imp1",
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ADomain: []string{"abc.com"},
DealID: "d1",
Expand Down Expand Up @@ -1059,9 +1060,9 @@ func TestGetPartnerRecordsByImpForDefaultBids(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
ID: "bid-id-2",
},
},
Expand Down Expand Up @@ -1141,9 +1142,9 @@ func TestGetPartnerRecordsByImpForDefaultBids(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
ID: "bid-id-1",
},
},
Expand Down Expand Up @@ -1313,9 +1314,9 @@ func TestGetPartnerRecordsByImpForSeatNonBid(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(exchange.ResponseRejectedBelowDealFloor),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
},
},
Expand Down Expand Up @@ -1343,9 +1344,9 @@ func TestGetPartnerRecordsByImpForSeatNonBid(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ID: "bid-id-1",
W: 10,
Expand Down Expand Up @@ -1444,9 +1445,9 @@ func TestGetPartnerRecordsByImpForSeatNonBidForFloors(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ID: "bid-id-1",
Floors: &openrtb_ext.ExtBidPrebidFloors{
Expand Down Expand Up @@ -1509,10 +1510,10 @@ func TestGetPartnerRecordsByImpForSeatNonBidForFloors(t *testing.T) {
NonBid: []openrtb_ext.NonBid{
{
ImpId: "imp1",
StatusCode: int((exchange.ResponseRejectedBelowFloor)),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ID: "bid-id-1",
Floors: &openrtb_ext.ExtBidPrebidFloors{
Expand Down Expand Up @@ -1575,10 +1576,10 @@ func TestGetPartnerRecordsByImpForSeatNonBidForFloors(t *testing.T) {
NonBid: []openrtb_ext.NonBid{
{
ImpId: "imp1",
StatusCode: int((exchange.ResponseRejectedBelowFloor)),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ID: "bid-id-1",
Floors: &openrtb_ext.ExtBidPrebidFloors{
Expand Down Expand Up @@ -1642,9 +1643,9 @@ func TestGetPartnerRecordsByImpForSeatNonBidForFloors(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ID: "bid-id-1",
},
Expand Down Expand Up @@ -1702,9 +1703,9 @@ func TestGetPartnerRecordsByImpForSeatNonBidForFloors(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ID: "bid-id-1",
},
Expand Down Expand Up @@ -1765,9 +1766,9 @@ func TestGetPartnerRecordsByImpForSeatNonBidForFloors(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(exchange.ResponseRejectedBelowFloor),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ID: "bid-id-1",
Floors: &openrtb_ext.ExtBidPrebidFloors{
Expand Down Expand Up @@ -2186,9 +2187,9 @@ func TestGetPartnerRecordsByImpForBidIDCollisions(t *testing.T) {
{
ImpId: "imp1",
StatusCode: int(nbr.LossBidLostToDealBid),
Ext: openrtb_ext.NonBidExt{
Prebid: openrtb_ext.ExtResponseNonBidPrebid{
Bid: openrtb_ext.NonBidObject{
Ext: openrtb_ext.ExtNonBid{
Prebid: openrtb_ext.ExtNonBidPrebid{
Bid: openrtb_ext.ExtNonBidPrebidBid{
Price: 10,
ID: "bid-id-1",
BidId: "uuid",
Expand Down Expand Up @@ -2485,8 +2486,8 @@ func TestGetPartnerRecordsByImpForBidExtFailure(t *testing.T) {
NonBid: []openrtb_ext.NonBid{
{
ImpId: "imp1",
StatusCode: int(nbr.LossBidLostToDealBid),
Ext: openrtb_ext.NonBidExt{},
StatusCode: int(exchange.ResponseRejectedBelowDealFloor),
Ext: openrtb_ext.ExtNonBid{},
},
},
},
Expand All @@ -2511,7 +2512,10 @@ func TestGetPartnerRecordsByImpForBidExtFailure(t *testing.T) {
NetECPM: 0,
GrossECPM: 0,
OriginalCur: models.USD,
Nbr: nbr.LossBidLostToDealBid.Ptr(),
Nbr: func() *openrtb3.NoBidReason {
a := exchange.ResponseRejectedBelowDealFloor
return &a
}(),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion analytics/pubstack/pubstack_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestNewModuleSuccess(t *testing.T) {
{
ImpId: "123",
StatusCode: 34,
Ext: openrtb_ext.NonBidExt{Prebid: openrtb_ext.ExtResponseNonBidPrebid{Bid: openrtb_ext.NonBidObject{}}},
Ext: openrtb_ext.ExtNonBid{Prebid: openrtb_ext.ExtNonBidPrebid{Bid: openrtb_ext.ExtNonBidPrebidBid{}}},
},
},
},
Expand Down
Loading
Loading