Skip to content

Commit

Permalink
UOE-11548: bid.ext.ibv support for OW (#961)
Browse files Browse the repository at this point in the history
* UOE-11548: bid.ext.ibv support for OW

* Nitpick

* NitPick
  • Loading branch information
AvinashKapre authored Dec 2, 2024
1 parent b653b44 commit 25a3dc4
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 5 deletions.
4 changes: 4 additions & 0 deletions modules/pubmatic/openwrap/auctionresponsehook.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func (m OpenWrap) handleAuctionResponseHook(
}
}

if bidExt.InBannerVideo {
m.metricEngine.RecordIBVRequest(rctx.PubIDStr, rctx.ProfileIDStr)
}

if rctx.IsCTVRequest {
if dur, ok := impCtx.BidIDToDur[bid.ID]; ok {
bidExt.Prebid.Video.Duration = int(dur)
Expand Down
5 changes: 3 additions & 2 deletions modules/pubmatic/openwrap/auctionresponsehook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ func TestOpenWrapHandleAuctionResponseHook(t *testing.T) {
ImpID: "Div1",
Price: 5,
AdM: "<img src=\"http://ads.pubmatic.com/AdTag/728x90.png\"></img><div style=\"position:absolute;left:0px;top:0px;visibility:hidden;\"><img src=\"https://t.pubmatic.com/wt?adv=&af=banner&aps=0&au=%2F43743431%2FDMDemo&bc=appnexus&bidid=4033c510-6d67-4af6-b53f-682ff1a580c3&di=-1&eg=14&en=14&frv=1.57&ft=0&fv=1.57&iid=429d469d-8cfb-495a-9f0c-5f48aa0ede40&kgpv=&orig=ebay.com&origbidid=718825584&pdvid=1&pid=22503&plt=1&pn=appnexus&psz=728x90&pubid=5890&purl=http%3A%2F%2Febay.com%2Finte%2Fautomation%2Fs2s_activation%2Fbanner-with-gdpr-pubmatic-denied-defaultbidder.html%3Fprofileid%3D22503%26pwtv%3D1%26pwtvc%3D1%26appnexus_banner_fixedbid%3D14%26fixedbid%3D1%26debug%3D1&sl=1&slot=%2F43743431%2FDMDemo&ss=1&tgid=0&tst=1704357774\"></div>",
Ext: json.RawMessage(`{"bidtype":0,"deal_channel":1,"dspid":6,"origbidcpm":8,"origbidcur":"USD","prebid":{"bidid":"bb57a9e3-fdc2-4772-8071-112dd7f50a6a","meta":{"adaptercode":"pubmatic","advertiserId":4098,"agencyId":4098,"demandSource":"6","mediaType":"banner","networkId":6},"targeting":{"hb_bidder_pubmatic":"pubmatic","hb_deal_pubmatic":"PUBDEAL1","hb_pb_pubmatic":"8.00","hb_size_pubmatic":"728x90"},"type":"banner","video":{"duration":0,"primary_category":"","vasttagid":""}}}`),
Ext: json.RawMessage(`{"bidtype":0,"deal_channel":1,"dspid":6,"origbidcpm":8,"origbidcur":"USD","ibv":true,"prebid":{"bidid":"bb57a9e3-fdc2-4772-8071-112dd7f50a6a","meta":{"adaptercode":"pubmatic","advertiserId":4098,"agencyId":4098,"demandSource":"6","mediaType":"banner","networkId":6},"targeting":{"hb_bidder_pubmatic":"pubmatic","hb_deal_pubmatic":"PUBDEAL1","hb_pb_pubmatic":"8.00","hb_size_pubmatic":"728x90"},"type":"banner","video":{"duration":0,"primary_category":"","vasttagid":""}}}`),
},
},
Seat: "pubmatic",
Expand All @@ -1682,6 +1682,7 @@ func TestOpenWrapHandleAuctionResponseHook(t *testing.T) {
mockEngine.EXPECT().RecordPublisherPartnerNoCookieStats("5890", gomock.Any()).AnyTimes()
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false).AnyTimes()
mockFeature.EXPECT().IsFscApplicable(gomock.Any(), gomock.Any(), gomock.Any()).Return(false)
mockEngine.EXPECT().RecordIBVRequest("5890", gomock.Any())
return mockEngine
},
doMutate: true,
Expand All @@ -1690,7 +1691,7 @@ func TestOpenWrapHandleAuctionResponseHook(t *testing.T) {
DebugMessages: []string{`[{"PubID":5890,"ProfileID":0,"DisplayID":0,"VersionID":0,"DisplayVersionID":0,"SSAuction":0,"SummaryDisable":0,"SSAI":"","PartnerConfigMap":{"-1":{"displayVersionId":"1","refreshInterval":"30","rev_share":"0.5"},"123":{"bidderCode":"pubmatic","kgp":"_AU_@_W_x_H_","partnerId":"123","prebidPartnerName":"pubmatic","serverSideEnabled":"1","timeout":"200"}},"SupportDeals":false,"Platform":"web","LoggerImpressionID":"","ClientConfigFlag":1,"IP":"","TMax":0,"IsTestRequest":0,"ABTestConfig":0,"ABTestConfigApplied":0,"IsCTVRequest":false,"TrackerEndpoint":"","VideoErrorTrackerEndpoint":"","UA":"","Cookies":"","UidCookie":null,"KADUSERCookie":null,"ParsedUidCookie":null,"OriginCookie":"","Debug":true,"Trace":false,"PageURL":"","StartTime":0,"DevicePlatform":0,"Trackers":{"bid-id-1":{"Tracker":{"PubID":5890,"PageURL":"","Timestamp":0,"IID":"","ProfileID":"0","VersionID":"0","SlotID":"","Adunit":"","PartnerInfo":{"PartnerID":"pubmatic","BidderCode":"pubmatic","KGPV":"","GrossECPM":0,"NetECPM":0,"BidID":"bb57a9e3-fdc2-4772-8071-112dd7f50a6a","OrigBidID":"bid-id-1","AdSize":"0x0","AdDuration":0,"Adformat":"banner","ServerSide":1,"Advertiser":"","FloorValue":0,"FloorRuleValue":0,"DealID":"-1"},"RewardedInventory":0,"SURL":"","Platform":0,"SSAI":"","AdPodSlot":0,"TestGroup":0,"Origin":"","FloorSkippedFlag":null,"FloorModelVersion":"","FloorSource":null,"FloorType":0,"CustomDimensions":"","LoggerData":{"KGPSV":"","FloorProvider":"","FloorFetchStatus":null}},"TrackerURL":"https:?adv=\u0026af=banner\u0026aps=0\u0026au=\u0026bc=pubmatic\u0026bidid=bb57a9e3-fdc2-4772-8071-112dd7f50a6a\u0026di=-1\u0026eg=0\u0026en=0\u0026ft=0\u0026iid=\u0026kgpv=\u0026orig=\u0026origbidid=bid-id-1\u0026pdvid=0\u0026pid=0\u0026plt=0\u0026pn=pubmatic\u0026psz=0x0\u0026pubid=5890\u0026purl=\u0026sl=1\u0026slot=\u0026ss=1\u0026tgid=0\u0026tst=0","ErrorURL":"","Price":5,"PriceModel":"CPM","PriceCurrency":""}},"PrebidBidderCode":null,"ImpBidCtx":{"Div1":{"ImpID":"","TagID":"","Div":"","SlotName":"","AdUnitName":"","Secure":0,"BidFloor":0,"BidFloorCur":"","IsRewardInventory":null,"Banner":true,"Video":{"mimes":null},"Native":null,"IncomingSlots":null,"Type":"video","Bidders":{"pubmatic":{"PartnerID":123,"PrebidBidderCode":"pubmatic","MatchedSlot":"","KGP":"","KGPV":"","IsRegex":false,"Params":null,"VASTTagFlag":false,"VASTTagFlags":null}},"NonMapped":null,"NewExt":null,"BidCtx":{"bid-id-1":{"prebid":{"meta":{"adaptercode":"pubmatic","advertiserId":4098,"agencyId":4098,"demandSource":"6","mediaType":"banner","networkId":6},"type":"banner","bidid":"bb57a9e3-fdc2-4772-8071-112dd7f50a6a"},"refreshInterval":30,"crtype":"banner","dspid":6,"netecpm":5,"origbidcpm":8,"origbidcur":"USD","EG":0,"EN":0}},"BannerAdUnitCtx":{"MatchedSlot":"","IsRegex":false,"MatchedRegex":"","SelectedSlotAdUnitConfig":null,"AppliedSlotAdUnitConfig":null,"UsingDefaultConfig":false,"AllowedConnectionTypes":null},"VideoAdUnitCtx":{"MatchedSlot":"","IsRegex":false,"MatchedRegex":"","SelectedSlotAdUnitConfig":null,"AppliedSlotAdUnitConfig":null,"UsingDefaultConfig":false,"AllowedConnectionTypes":null},"BidderError":"","IsAdPodRequest":false}},"Aliases":null,"NewReqExt":null,"ResponseExt":{"responsetimemillis":{"pubmatic":8}},"MarketPlaceBidders":null,"AdapterThrottleMap":null,"AdUnitConfig":null,"Source":"","Origin":"","SendAllBids":false,"WinningBids":{"Div1":{"ID":"bid-id-1","NetEcpm":5,"BidDealTierSatisfied":false,"Nbr":null}},"DroppedBids":null,"DefaultBids":{},"SeatNonBids":{},"BidderResponseTimeMillis":{"pubmatic":8},"Endpoint":"","PubIDStr":"5890","ProfileIDStr":"","MetricsEngine":{},"ReturnAllBidStatus":true,"Sshb":"","DCName":"","CachePutMiss":0,"MatchedImpression":{"pubmatic":0},"CustomDimensions":null}]`},
},
err: nil,
bidResponse: json.RawMessage(`{"id":"12345","seatbid":[{"bid":[{"id":"bid-id-1","impid":"Div1","price":5,"adm":"\u003cimg src=\"http://ads.pubmatic.com/AdTag/728x90.png\"\u003e\u003c/img\u003e\u003cdiv style=\"position:absolute;left:0px;top:0px;visibility:hidden;\"\u003e\u003cimg src=\"https://t.pubmatic.com/wt?adv=\u0026af=banner\u0026aps=0\u0026au=%2F43743431%2FDMDemo\u0026bc=appnexus\u0026bidid=4033c510-6d67-4af6-b53f-682ff1a580c3\u0026di=-1\u0026eg=14\u0026en=14\u0026frv=1.57\u0026ft=0\u0026fv=1.57\u0026iid=429d469d-8cfb-495a-9f0c-5f48aa0ede40\u0026kgpv=\u0026orig=ebay.com\u0026origbidid=718825584\u0026pdvid=1\u0026pid=22503\u0026plt=1\u0026pn=appnexus\u0026psz=728x90\u0026pubid=5890\u0026purl=http%3A%2F%2Febay.com%2Finte%2Fautomation%2Fs2s_activation%2Fbanner-with-gdpr-pubmatic-denied-defaultbidder.html%3Fprofileid%3D22503%26pwtv%3D1%26pwtvc%3D1%26appnexus_banner_fixedbid%3D14%26fixedbid%3D1%26debug%3D1\u0026sl=1\u0026slot=%2F43743431%2FDMDemo\u0026ss=1\u0026tgid=0\u0026tst=1704357774\"\u003e\u003c/div\u003e\u003cdiv style=\"position:absolute;left:0px;top:0px;visibility:hidden;\"\u003e\u003cimg src=\"https:?adv=\u0026af=banner\u0026aps=0\u0026au=\u0026bc=pubmatic\u0026bidid=bb57a9e3-fdc2-4772-8071-112dd7f50a6a\u0026di=-1\u0026eg=0\u0026en=0\u0026ft=0\u0026iid=\u0026kgpv=\u0026orig=\u0026origbidid=bid-id-1\u0026pdvid=0\u0026pid=0\u0026plt=0\u0026pn=pubmatic\u0026psz=0x0\u0026pubid=5890\u0026purl=\u0026sl=1\u0026slot=\u0026ss=1\u0026tgid=0\u0026tst=0\"\u003e\u003c/div\u003e","ext":{"prebid":{"meta":{"adaptercode":"pubmatic","advertiserId":4098,"agencyId":4098,"demandSource":"6","mediaType":"banner","networkId":6},"type":"banner","bidid":"bb57a9e3-fdc2-4772-8071-112dd7f50a6a"},"refreshInterval":30,"crtype":"banner","dspid":6,"netecpm":5,"origbidcpm":8,"origbidcur":"USD"}}],"seat":"pubmatic"}],"ext":{"responsetimemillis":{"pubmatic":8},"matchedimpression":{"pubmatic":0}}}`),
bidResponse: json.RawMessage(`{"id":"12345","seatbid":[{"bid":[{"id":"bid-id-1","impid":"Div1","price":5,"adm":"\u003cimg src=\"http://ads.pubmatic.com/AdTag/728x90.png\"\u003e\u003c/img\u003e\u003cdiv style=\"position:absolute;left:0px;top:0px;visibility:hidden;\"\u003e\u003cimg src=\"https://t.pubmatic.com/wt?adv=\u0026af=banner\u0026aps=0\u0026au=%2F43743431%2FDMDemo\u0026bc=appnexus\u0026bidid=4033c510-6d67-4af6-b53f-682ff1a580c3\u0026di=-1\u0026eg=14\u0026en=14\u0026frv=1.57\u0026ft=0\u0026fv=1.57\u0026iid=429d469d-8cfb-495a-9f0c-5f48aa0ede40\u0026kgpv=\u0026orig=ebay.com\u0026origbidid=718825584\u0026pdvid=1\u0026pid=22503\u0026plt=1\u0026pn=appnexus\u0026psz=728x90\u0026pubid=5890\u0026purl=http%3A%2F%2Febay.com%2Finte%2Fautomation%2Fs2s_activation%2Fbanner-with-gdpr-pubmatic-denied-defaultbidder.html%3Fprofileid%3D22503%26pwtv%3D1%26pwtvc%3D1%26appnexus_banner_fixedbid%3D14%26fixedbid%3D1%26debug%3D1\u0026sl=1\u0026slot=%2F43743431%2FDMDemo\u0026ss=1\u0026tgid=0\u0026tst=1704357774\"\u003e\u003c/div\u003e\u003cdiv style=\"position:absolute;left:0px;top:0px;visibility:hidden;\"\u003e\u003cimg src=\"https:?adv=\u0026af=banner\u0026aps=0\u0026au=\u0026bc=pubmatic\u0026bidid=bb57a9e3-fdc2-4772-8071-112dd7f50a6a\u0026di=-1\u0026eg=0\u0026en=0\u0026ft=0\u0026iid=\u0026kgpv=\u0026orig=\u0026origbidid=bid-id-1\u0026pdvid=0\u0026pid=0\u0026plt=0\u0026pn=pubmatic\u0026psz=0x0\u0026pubid=5890\u0026purl=\u0026sl=1\u0026slot=\u0026ss=1\u0026tgid=0\u0026tst=0\"\u003e\u003c/div\u003e","ext":{"prebid":{"meta":{"adaptercode":"pubmatic","advertiserId":4098,"agencyId":4098,"demandSource":"6","mediaType":"banner","networkId":6},"type":"banner","bidid":"bb57a9e3-fdc2-4772-8071-112dd7f50a6a"},"refreshInterval":30,"crtype":"banner","dspid":6,"netecpm":5,"origbidcpm":8,"origbidcur":"USD","ibv":true}}],"seat":"pubmatic"}],"ext":{"responsetimemillis":{"pubmatic":8},"matchedimpression":{"pubmatic":0}}}`),
},
},
{
Expand Down
7 changes: 7 additions & 0 deletions modules/pubmatic/openwrap/metrics/config/multimetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@ func (me *MultiMetricsEngine) RecordEndpointResponseSize(endpoint string, bodySi
}
}

// RecordIBVRequest record failed parsing itune id
func (me *MultiMetricsEngine) RecordIBVRequest(pubId, profId string) {
for _, thisME := range *me {
thisME.RecordIBVRequest(pubId, profId)
}
}

// RecordBidRecoveryStatus across all engines
func (me *MultiMetricsEngine) RecordBidRecoveryStatus(publisher, profile string, success bool) {
for _, thisME := range *me {
Expand Down
2 changes: 2 additions & 0 deletions modules/pubmatic/openwrap/metrics/config/multimetrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func TestRecordFunctionForMultiMetricsEngine(t *testing.T) {
mockEngine.EXPECT().RecordOWServerPanic("endpoint", "methodName", "nodeName", "podName")
mockEngine.EXPECT().RecordAmpVideoRequests("pubid", "profileid")
mockEngine.EXPECT().RecordAmpVideoResponses("pubid", "profileid")
mockEngine.EXPECT().RecordIBVRequest("pubid", "profileid")
mockEngine.EXPECT().RecordBidRecoveryStatus(publisher, profile, true)
mockEngine.EXPECT().RecordBidRecoveryResponseTime(publisher, profile, time.Duration(200))

Expand Down Expand Up @@ -290,6 +291,7 @@ func TestRecordFunctionForMultiMetricsEngine(t *testing.T) {
multiMetricEngine.RecordOWServerPanic("endpoint", "methodName", "nodeName", "podName")
multiMetricEngine.RecordAmpVideoRequests("pubid", "profileid")
multiMetricEngine.RecordAmpVideoResponses("pubid", "profileid")
multiMetricEngine.RecordIBVRequest("pubid", "profileid")
multiMetricEngine.RecordBidRecoveryStatus(publisher, profile, true)
multiMetricEngine.RecordBidRecoveryResponseTime(publisher, profile, time.Duration(200))
}
3 changes: 3 additions & 0 deletions modules/pubmatic/openwrap/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,7 @@ type MetricsEngine interface {
//AppLovinMax metrics
RecordFailedParsingItuneID(pubId, profId string)
RecordEndpointResponseSize(endpoint string, bodySize float64)

//IBV metric
RecordIBVRequest(pubId, profId string)
}
12 changes: 12 additions & 0 deletions modules/pubmatic/openwrap/metrics/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions modules/pubmatic/openwrap/metrics/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ type Metrics struct {
//ApplovinMax
failedParsingItuneId *prometheus.CounterVec
endpointResponseSize *prometheus.HistogramVec

//IBV request
ibvRequests *prometheus.CounterVec
}

const (
Expand Down Expand Up @@ -380,6 +383,10 @@ func newMetrics(cfg *config.PrometheusMetrics, promRegistry *prometheus.Registry
responseSizeBuckets,
)

metrics.ibvRequests = newCounter(cfg, promRegistry,
"ibv_requests",
"Count of in-banner video requests",
[]string{pubIDLabel, profileIDLabel})
metrics.pubBidRecoveryTime = newHistogramVec(cfg, promRegistry,
"bid_recovery_response_time",
"Total time taken by request for secondary auction in ms at publisher profile level.",
Expand Down Expand Up @@ -625,12 +632,20 @@ func (m *Metrics) RecordSignalDataStatus(pubid, profileid, signalType string) {
}).Inc()
}

func (m *Metrics) RecordFailedParsingItuneID(pubId, profId string) {
// RecordFailedParsingItuneID to record failed parsing itune id
func (m *Metrics) RecordFailedParsingItuneID(pubid, profileid string) {
m.failedParsingItuneId.With(prometheus.Labels{
pubIDLabel: pubId,
profileIDLabel: profId,
pubIDLabel: pubid,
profileIDLabel: profileid,
}).Inc()
}

// RecordIBVRequest to record IBV request
func (m *Metrics) RecordIBVRequest(pubid, profileid string) {
m.ibvRequests.With(prometheus.Labels{
pubIDLabel: pubid,
profileIDLabel: profileid,
}).Inc()
}

// TODO - really need ?
Expand Down
14 changes: 14 additions & 0 deletions modules/pubmatic/openwrap/metrics/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,20 @@ func TestRecordDBQueryFailure(t *testing.T) {
})
}

func TestRecordIBVRequest(t *testing.T) {
m := createMetricsForTesting()

m.RecordIBVRequest("5890", "59201")

expectedCount := float64(1)
assertCounterVecValue(t, "", "ibv_requests", m.ibvRequests,
expectedCount,
prometheus.Labels{
pubIDLabel: "5890",
profileIDLabel: "59201",
})
}

func TestRecordSignalDataStatus(t *testing.T) {
m := createMetricsForTesting()

Expand Down
1 change: 1 addition & 0 deletions modules/pubmatic/openwrap/metrics/stats/tcp_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,4 @@ func (st *StatsTCP) RecordPrebidAuctionBidResponse(publisher string, partnerName
}
func (st *StatsTCP) RecordFailedParsingItuneID(pubId, profId string) {}
func (st *StatsTCP) RecordEndpointResponseSize(endpoint string, bodySize float64) {}
func (st *StatsTCP) RecordIBVRequest(pubId, profId string) {}
1 change: 1 addition & 0 deletions modules/pubmatic/openwrap/models/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type BidExt struct {
Fsc int `json:"fsc,omitempty"`
AdPod *AdpodBidExt `json:"adpod,omitempty"`
MultiBidMultiFloorValue float64 `json:"-"`
InBannerVideo bool `json:"ibv,omitempty"`
}

type AdpodBidExt struct {
Expand Down

0 comments on commit 25a3dc4

Please sign in to comment.