Skip to content

Commit

Permalink
OTT-1073: introduce the stats in Pubmatic OW module (#516)
Browse files Browse the repository at this point in the history
* add improvements to ow module

* use concrete adunit, major refactor, complete tracker

* complete logger

* logger complete

* go mod tidy

* INCOMPLETE: move hookexecutor at request level

* multi cur and pubmatic seat = 0

* INCOMPLETE: move hookexecutor at request level

* bug fixes 1

* add module rejection and start adunitconfig

* adunit cfg done

* minor fixes

* minor fixes 2

* use rctx for response, logger, tracker

* typo

* minor improvements

* add processed auction hook

* send all bids done

* minor fix: send all bids

* fix: vast tag cache timeout

* assert ow bidder initialisation

* fix: log dropped bids in owlogger

* fix the condition to eval droppedbids

* owlogger always logs wb

* fix account level bidderparams

* add nobid

* fix: false nobids

* remove stale non prebid ext

* matched impression

* user seeat for partnerid in wl

* complete video bid ext

* fix pn in wl

* complete marketplace wl and minor request patches

* complete regex and minor bug fixes

* fix adapter throttle

* fix wl pn

* verbose logging for module panic

* add module ctx assertion logs

* fix pn in wt

* af for nobid

* TEMP: LOCAL DOCKER

* add response.ext.sendallbids

* fix af

* dont log throttle-nobid in wl

* ignore manual_build

* fix: dont log throttle-nobid in wl

* ab test

* temp. fix bid.ext.prebid.video

* tgid if wl

* case insensitive slotname

* fix: client config

* typo

* fix1 GetClientConfigForMediaType

* remove duplicate bidext.perbid

* pubmatic default mapping refactor, regex todo

* add bidExt.Prebid nil assertion

* REVIEW: kgp, kgpv, kgpsv

* fix imp.ext.reward

* nobid for non-mapped bidders

* assert module rejection + alias

* fix bidder param hw typo

* slot regex + package cache refactor

* fix generate slot regex based name

* fix slot key gen

* regex slot wl fix

* wt kgpv

* fix dmx alias

* kgpsv typo

* macro ssai fix

* drop bids safely

* improve contenttransperencyobject.go

* fix video adunit apply typo

* sendallbids typo

* sendallbids typo 2

* video adunit battr typo

* go fmt

* change gomod name

* refactor nobid cases

* fix: fill fieldMap for pubmatic

* fix marketplace wl wt kgp*

* fix pubmatic kgpv overwrite

* fix pn pubmatic for marketplace bids

* fix: adunit regex check and req.user nil  typo

* fix wl gdpr

* fix user consent in wl

* add request.device validation

* minor wl refactor

* client client config banner format condition

* do not sent client config if it is disabled

* multiformat wl slot

* fix typo

* ignore 0x0 in sz

* fix last bad fix

* refactor sz

* refactor GetClientConfigForMediaType

* handle nobid GetClientConfigForMediaType

* handle imp type + fix ExtDevice

* fix multiformat kgpv kgpsv

* Check when bid.H and bid.W will be zero with Price !=0. Ex

* handle nil device.ext

* p1 GetClientConfigForMediaType

* get AU for V and B but apply only if req not nil

* move ow bidder param to pbs

* compete tracker

* fix tracker wrong param reference

* inject only one tracker in video

* fix dmx

* logInfo and minor refactor

* loginfo minor typos

* fix device ext ifa missing cases

* fix test = 1

* basic nbr, remove errorcodes

* add nbr scenarios

* fix auction race condition and floors adunit type

* add floor rules wrapper logger changes

* add pyroscope

* fix race condition

* add l1 in wl and minor wl refactor

* add rejected bids to wl

* rebuild tracker url for groupm

* fix fv in wl

* minor improvement for fr in wl

* default imp floor assertion

* add bidderparams for pubmatic2

* dv 360

* fix pubmatic2

* fix pb2

* add seatnobid in response

* typo

* include full bid in seatnobid

* update response ext with nbr

* minor imp

* update responseext with ow fields

* refactor response ext

* minor resp rctx refactor

* fix analyctis's request is nil for entry hook rejection

* minor refactor

* use concrete response ext type

* add client config for seatnobid

* fix wl for nbr

* refactor tmax

* add pprof

* add http_counter metrics

* move db queries to config

* refactor db query create

* fix wl client

* temp: video endpoint

* minor debug log improvements

* pyroscope read hostname

* pbs fix and minor improvement

* minor improvement in wl

* wl remove dead code

* use internal wl endpoint for call from s2s

* use gocommon client for wl

* add db connect log

* minor refactor

* add entrypoint hook test

* minor entrypoint refactor and test update

* prc 1

* bidderparams refactor

* remove redudant module to get account id

* remove pyroscope

* minor refactor

* fix: rebase typos

* club ow + sshb

* fix unimportable main

* update openrtb v17 to v19

* revert wrong commit

* use empty hook

* comment seatnonbid

* revert unintended changes

* fix typo

* remove duplicate content

* rename pbs.yaml

* remove config param mapping

* fix formatting

* fix module name

* add sshb flag

* fix sshb path checks

* update sshb tests

* fix FloorValueUSD UT

* Revert "Sharethrough: Support native ads (prebid#2780)"

This reverts commit de804a5.

* Revert "Appnexus: Add ext_inv_code and external_imp_id parameters (prebid#2792)"

This reverts commit 225e31e.

* Revert "Move httputil/responseutil to adapters/util and adapters/openrtb_util to exchange/util (prebid#2788)"

This reverts commit 0615109.

* Revert "PREB-39 added support for imp.ext and added imp.ext.skadn to it (prebid#2770)"

This reverts commit d527e2f.

* Revert "HuaweiAds: Handle getDeviceIDFromUserExt when ifa and user.ext are set (prebid#2796)"

This reverts commit 3a5d7c9.

* Revert "GPP in the cookie sync endpoint (prebid#2757)"

This reverts commit 708d917.

* OTT-1104: Move the stat-server from HB to prebid

* address test = 1 and 2

* fix test=2

* rename analytics and remove unused files

* remove wrong commit

* minor refactor

* add mockgen and db test

* migrate fsc db and cache code

* create cache mock

* update db mock

* add db sql driver mock

* OTT-1124: add graceful shutdown function for stats-server (#512)

* update universalpixel in auc

* make UniversalPixel ptr in auc

* correct UniversalPixel type in auc

* OTT-1073: add stats at before-validation stage

* OTT-1073: updated go.mod

* OTT-1124: add shutdown function for stats metric-engine

* OTT-1073: add shutdown across all metric-engine

* OTT-1073: adding stats at auction-response stage

* OTT-1073: add pubIDStr and profIDStr in rCtx

* OTT-1073: added UT for multi metric engine

* OTT-1073: remove unwanted comments

* OTT-1127 : Removed un-used stats metrics (#517)

* OTT-1127: remove unused functions from metricEngine

* auc: add native

* auc: add lower case kv of config

* auc: fix config json tag

* auc: add omitempty

* OTT-1073: record bad-requests, bidder-error stats, resp-time

* auc: uncomment json tag

* OTT-1073: record wrapper-logger-failures

* fix err typo in GetActivePartnerConfigurations

* disable floors wl code until modules is enabled

* Revert "disable floors wl code until modules is enabled"

This reverts commit 3354753.

* TEMP: coment FloorValueUSD

* OTT-1073: RecordMisConfigurationErrorStats

* OTT-1073: RecordPublisherPartnerNoCookieStats

* OTT-1073:RecordPublisherRequests

* OTT-1073: address review comments

* OTT-1073: address review comments

* OTT-1073: minor fix

* OTT-1073: fix GetLogAuctionObjectAsURL

* OTT-1073: make metricsengine as a part of request-ctx

* OTT-1073: do not record stat-metric for owlogger failure

* OTT-1073: fix error statement in logAuctionObject

* OTT-1073: remove log statement from LogAuctionObject

---------

Co-authored-by: Nilesh Chate <nilesh.chate@pubmatic.com>
Co-authored-by: Ankit-Pinge <128145896+Ankit-Pinge@users.noreply.github.com>
  • Loading branch information
3 people committed Jul 14, 2023
1 parent 70ab57a commit 4deddf6
Show file tree
Hide file tree
Showing 32 changed files with 1,743 additions and 307 deletions.
6 changes: 1 addition & 5 deletions analytics/pubmatic/logger.go
Expand Up @@ -13,11 +13,7 @@ import (
"github.com/prebid/prebid-server/openrtb_ext"
)

func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, logInfo, forRespExt bool) (string, http.Header) {
rCtx := GetRequestCtx(ao.HookExecutionOutcome)
if rCtx == nil {
return "", http.Header{}
}
func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, rCtx *models.RequestCtx, logInfo, forRespExt bool) (string, http.Header) {

wlog := WloggerRecord{
record: record{
Expand Down
18 changes: 16 additions & 2 deletions analytics/pubmatic/pubmatic.go
Expand Up @@ -38,9 +38,23 @@ func (ow HTTPLogger) LogAuctionObject(ao *analytics.AuctionObject) {
}
}()

url, headers := GetLogAuctionObjectAsURL(*ao, false, false)
rCtx := GetRequestCtx(ao.HookExecutionOutcome)
if rCtx == nil {
// glog.Errorf("Failed to get the request context for AuctionObject - [%v]", ao)
// add this log once complete header-bidding code is migrated to modules
return
}

var err error
url, headers := GetLogAuctionObjectAsURL(*ao, rCtx, false, false)
if url != "" {
Send(url, headers)
err = Send(url, headers)
}

// record the logger failure
if url == "" || err != nil {
glog.Errorf("Failed to send the owlogger for pub:[%d], profile:[%d], version:[%d].",
rCtx.PubID, rCtx.ProfileID, rCtx.VersionID)
}
}

Expand Down
4 changes: 2 additions & 2 deletions endpoints/openrtb2/auction_ow.go
Expand Up @@ -61,7 +61,7 @@ func UpdateResponseExtOW(bidResponse *openrtb2.BidResponse, ao analytics.Auction
}

if rCtx.LogInfoFlag == 1 {
extBidResponse.OwLogInfo.Logger, _ = pubmatic.GetLogAuctionObjectAsURL(ao, true, true)
extBidResponse.OwLogInfo.Logger, _ = pubmatic.GetLogAuctionObjectAsURL(ao, rCtx, true, true)
}

// TODO: uncomment after seatnonbid PR is merged https://github.com/prebid/prebid-server/pull/2505
Expand All @@ -73,7 +73,7 @@ func UpdateResponseExtOW(bidResponse *openrtb2.BidResponse, ao analytics.Auction
// }

if rCtx.Debug {
extBidResponse.OwLogger, _ = pubmatic.GetLogAuctionObjectAsURL(ao, false, true)
extBidResponse.OwLogger, _ = pubmatic.GetLogAuctionObjectAsURL(ao, rCtx, false, true)
}

bidResponse.Ext, _ = json.Marshal(extBidResponse)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -48,6 +48,7 @@ require (
github.com/go-sql-driver/mysql v1.7.0
github.com/satori/go.uuid v1.2.0
github.com/golang/mock v1.6.0
github.com/satori/go.uuid v1.2.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions modules/pubmatic/openwrap/adunitconfig/banner.go
Expand Up @@ -25,6 +25,7 @@ func UpdateBannerObjectWithAdunitConfig(rCtx models.RequestCtx, imp openrtb2.Imp
if defaultAdUnitConfig.Banner != nil && defaultAdUnitConfig.Banner.Enabled != nil && !*defaultAdUnitConfig.Banner.Enabled {
f := false
adUnitCtx.AppliedSlotAdUnitConfig = &adunitconfig.AdConfig{Banner: &adunitconfig.Banner{Enabled: &f}}
rCtx.MetricsEngine.RecordImpDisabledViaConfigStats(models.ImpTypeBanner, rCtx.PubIDStr, rCtx.ProfileIDStr)
return
}
}
Expand All @@ -44,6 +45,7 @@ func UpdateBannerObjectWithAdunitConfig(rCtx models.RequestCtx, imp openrtb2.Imp
if adUnitCtx.SelectedSlotAdUnitConfig.Banner.Enabled != nil && !*adUnitCtx.SelectedSlotAdUnitConfig.Banner.Enabled {
f := false
adUnitCtx.AppliedSlotAdUnitConfig = &adunitconfig.AdConfig{Banner: &adunitconfig.Banner{Enabled: &f}}
rCtx.MetricsEngine.RecordImpDisabledViaConfigStats(models.ImpTypeBanner, rCtx.PubIDStr, rCtx.ProfileIDStr)
return
}
}
Expand Down
3 changes: 3 additions & 0 deletions modules/pubmatic/openwrap/adunitconfig/video.go
Expand Up @@ -28,6 +28,7 @@ func UpdateVideoObjectWithAdunitConfig(rCtx models.RequestCtx, imp openrtb2.Imp,
if defaultAdUnitConfig.Video != nil && defaultAdUnitConfig.Video.Enabled != nil && !*defaultAdUnitConfig.Video.Enabled {
f := false
adUnitCtx.AppliedSlotAdUnitConfig = &adunitconfig.AdConfig{Video: &adunitconfig.Video{Enabled: &f}}
rCtx.MetricsEngine.RecordImpDisabledViaConfigStats(models.ImpTypeVideo, rCtx.PubIDStr, rCtx.ProfileIDStr)
return
}
}
Expand All @@ -44,6 +45,7 @@ func UpdateVideoObjectWithAdunitConfig(rCtx models.RequestCtx, imp openrtb2.Imp,
if adUnitCtx.SelectedSlotAdUnitConfig.Video.Enabled != nil && !*adUnitCtx.SelectedSlotAdUnitConfig.Video.Enabled {
f := false
adUnitCtx.AppliedSlotAdUnitConfig = &adunitconfig.AdConfig{Video: &adunitconfig.Video{Enabled: &f}}
rCtx.MetricsEngine.RecordImpDisabledViaConfigStats(models.ImpTypeVideo, rCtx.PubIDStr, rCtx.ProfileIDStr)
return
}
}
Expand Down Expand Up @@ -71,6 +73,7 @@ func UpdateVideoObjectWithAdunitConfig(rCtx models.RequestCtx, imp openrtb2.Imp,
// if allowedConnectionTypes != nil && !checkValuePresentInArray(allowedConnectionTypes, int(*connectionType)) {
// f := false
// adUnitCtx.AppliedSlotAdUnitConfig = &adunitconfig.AdConfig{Video: &adunitconfig.Video{Enabled: &f}}
// rCtx.MetricsEngine.RecordVideoImpDisabledViaConnTypeStats(rCtx.PubIDStr,rCtx.ProfIDStr)
// return
// }
// }
Expand Down
24 changes: 17 additions & 7 deletions modules/pubmatic/openwrap/auctionresponsehook.go
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"strconv"
"time"

"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/hooks/hookanalytics"
Expand Down Expand Up @@ -34,8 +35,11 @@ func (m OpenWrap) handleAuctionResponseHook(
}
defer func() {
moduleCtx.ModuleContext["rctx"] = rctx
m.metricEngine.RecordPublisherResponseTimeStats(rctx.PubIDStr, int(time.Since(time.Unix(rctx.StartTime, 0)).Milliseconds()))
}()

RecordPublisherPartnerNoCookieStats(rctx)

// cache rctx for analytics
result.AnalyticsTags = hookanalytics.Analytics{
Activities: []hookanalytics.Activity{
Expand All @@ -59,12 +63,14 @@ func (m OpenWrap) handleAuctionResponseHook(
winningBids := make(map[string]models.OwBid, 0)
for _, seatBid := range payload.BidResponse.SeatBid {
for _, bid := range seatBid.Bid {

m.metricEngine.RecordPlatformPublisherPartnerResponseStats(rctx.Platform, rctx.PubIDStr, seatBid.Seat)

impCtx, ok := rctx.ImpBidCtx[bid.ImpID]
if !ok {
result.Errors = append(result.Errors, "invalid impCtx.ID for bid"+bid.ImpID)
continue
}

partnerID := 0
if bidderMeta, ok := impCtx.Bidders[seatBid.Seat]; ok {
partnerID = bidderMeta.PartnerID
Expand Down Expand Up @@ -169,6 +175,9 @@ func (m OpenWrap) handleAuctionResponseHook(
}

rctx.WinningBids = winningBids
if len(winningBids) == 0 {
m.metricEngine.RecordNobidErrPrebidServerResponse(rctx.PubIDStr)
}

droppedBids, warnings := addPWTTargetingForBid(rctx, payload.BidResponse)
if len(droppedBids) != 0 {
Expand All @@ -178,10 +187,6 @@ func (m OpenWrap) handleAuctionResponseHook(
result.Warnings = append(result.Warnings, warnings...)
}

rctx.NoSeatBids = m.addDefaultBids(rctx, payload.BidResponse)

rctx.Trackers = tracker.CreateTrackers(rctx, payload.BidResponse)

responseExt := openrtb_ext.ExtBidResponse{}
// TODO use concrete structure
if len(payload.BidResponse.Ext) != 0 {
Expand All @@ -190,8 +195,13 @@ func (m OpenWrap) handleAuctionResponseHook(
}
}

for k, v := range responseExt.ResponseTimeMillis {
rctx.BidderResponseTimeMillis[k.String()] = v
rctx.NoSeatBids = m.addDefaultBids(rctx, payload.BidResponse, &responseExt)

rctx.Trackers = tracker.CreateTrackers(rctx, payload.BidResponse)

for bidder, responseTimeMs := range responseExt.ResponseTimeMillis {
rctx.BidderResponseTimeMillis[bidder.String()] = responseTimeMs
m.metricEngine.RecordPartnerResponseTimeStats(rctx.PubIDStr, string(bidder), responseTimeMs)
}

// TODO: PBS-Core should pass the hostcookie for module to usersync.ParseCookieFromRequest()
Expand Down
53 changes: 50 additions & 3 deletions modules/pubmatic/openwrap/beforevalidationhook.go
Expand Up @@ -39,6 +39,10 @@ func (m OpenWrap) handleBeforeValidationHook(
}
defer func() {
moduleCtx.ModuleContext["rctx"] = rCtx
if len(result.Errors) > 0 {
m.metricEngine.RecordBadRequests(rCtx.Endpoint, getPubmaticErrorCode(result.NbrCode))

}
}()

pubID, err := getPubID(*payload.BidRequest)
Expand All @@ -48,6 +52,12 @@ func (m OpenWrap) handleBeforeValidationHook(
return result, fmt.Errorf("invalid publisher id : %v", err)
}
rCtx.PubID = pubID
rCtx.PubIDStr = strconv.Itoa(pubID)

if rCtx.UidCookie == nil {
m.metricEngine.RecordUidsCookieNotPresentErrorStats(rCtx.PubIDStr, rCtx.ProfileIDStr)
}
m.metricEngine.RecordPublisherProfileRequests(rCtx.PubIDStr, rCtx.ProfileIDStr)

requestExt, err := models.GetRequestExt(payload.BidRequest.Ext)
if err != nil {
Expand All @@ -68,17 +78,30 @@ func (m OpenWrap) handleBeforeValidationHook(
result.NbrCode = nbr.InvalidProfileConfiguration
err = errors.New("failed to get profile data: " + err.Error())
result.Errors = append(result.Errors, err.Error())
m.metricEngine.RecordPublisherInvalidProfileRequests(rCtx.Endpoint, rCtx.PubIDStr, rCtx.ProfileIDStr)
m.metricEngine.RecordPublisherInvalidProfileImpressions(rCtx.PubIDStr, rCtx.ProfileIDStr, len(payload.BidRequest.Imp))
return result, err
}

rCtx.PartnerConfigMap = partnerConfigMap // keep a copy at module level as well
rCtx.Platform, _ = rCtx.GetVersionLevelKey(models.PLATFORM_KEY)
if rCtx.Platform == "" {
result.NbrCode = nbr.InvalidPlatform
err = errors.New("failed to get platform data")
result.Errors = append(result.Errors, err.Error())
m.metricEngine.RecordPublisherInvalidProfileRequests(rCtx.Endpoint, rCtx.PubIDStr, rCtx.ProfileIDStr)
m.metricEngine.RecordPublisherInvalidProfileImpressions(rCtx.PubIDStr, rCtx.ProfileIDStr, len(payload.BidRequest.Imp))
return result, err
}

rCtx.PageURL = getPageURL(payload.BidRequest)
rCtx.DevicePlatform = GetDevicePlatform(rCtx.UA, payload.BidRequest, rCtx.Platform)
rCtx.SendAllBids = isSendAllBids(rCtx)
rCtx.Source, rCtx.Origin = getSourceAndOrigin(payload.BidRequest)
rCtx.TMax = m.setTimeout(rCtx)

m.metricEngine.RecordPublisherRequests(rCtx.Endpoint, rCtx.PubIDStr, rCtx.Platform)

if newPartnerConfigMap, ok := ABTestProcessing(rCtx); ok {
rCtx.ABTestConfigApplied = 1
rCtx.PartnerConfigMap = newPartnerConfigMap
Expand All @@ -91,6 +114,7 @@ func (m OpenWrap) handleBeforeValidationHook(
result.NbrCode = nbr.AllPartnerThrottled
result.Errors = append(result.Errors, "All adapters throttled")
rCtx.ImpBidCtx = getDefaultImpBidCtx(*payload.BidRequest) // for wrapper logger sz
m.metricEngine.RecordNobidErrPrebidServerRequests(rCtx.PubIDStr)
return result, err
}

Expand All @@ -100,6 +124,7 @@ func (m OpenWrap) handleBeforeValidationHook(
err = errors.New("failed to price granularity details: " + err.Error())
result.Errors = append(result.Errors, err.Error())
rCtx.ImpBidCtx = getDefaultImpBidCtx(*payload.BidRequest) // for wrapper logger sz
m.metricEngine.RecordNobidErrPrebidServerRequests(rCtx.PubIDStr)
return result, err
}

Expand All @@ -126,12 +151,19 @@ func (m OpenWrap) handleBeforeValidationHook(
result.NbrCode = nbr.InvalidImpressionTagID
err = errors.New("tagid missing for imp: " + imp.ID)
result.Errors = append(result.Errors, err.Error())
m.metricEngine.RecordNobidErrPrebidServerRequests(rCtx.PubIDStr)
return result, err
}

if len(requestExt.Prebid.Macros) == 0 && imp.Video != nil {
// provide custom macros for video event trackers
requestExt.Prebid.Macros = getVASTEventMacros(rCtx)
if imp.Video != nil {
//add stats for video instl impressions
if imp.Instl == 1 {
m.metricEngine.RecordVideoInstlImpsStats(rCtx.PubIDStr, rCtx.ProfileIDStr)
}
if len(requestExt.Prebid.Macros) == 0 {
// provide custom macros for video event trackers
requestExt.Prebid.Macros = getVASTEventMacros(rCtx)
}
}

impExt := &models.ImpExtension{}
Expand All @@ -141,6 +173,7 @@ func (m OpenWrap) handleBeforeValidationHook(
result.NbrCode = nbr.InternalError
err = errors.New("failed to parse imp.ext: " + imp.ID)
result.Errors = append(result.Errors, err.Error())
m.metricEngine.RecordNobidErrPrebidServerRequests(rCtx.PubIDStr)
return result, err
}
}
Expand All @@ -154,6 +187,15 @@ func (m OpenWrap) handleBeforeValidationHook(

var videoAdUnitCtx, bannerAdUnitCtx models.AdUnitCtx
if rCtx.AdUnitConfig != nil {
// Currently we are supporting Video config via Ad Unit config file for in-app / video / display profiles
if (rCtx.Platform == models.PLATFORM_APP || rCtx.Platform == models.PLATFORM_VIDEO || rCtx.Platform == models.PLATFORM_DISPLAY) && imp.Video != nil {
if payload.BidRequest.App != nil && payload.BidRequest.App.Content != nil {
m.metricEngine.RecordReqImpsWithAppContentCount(rCtx.PubIDStr)
}
if payload.BidRequest.Site != nil && payload.BidRequest.Site.Content != nil {
m.metricEngine.RecordReqImpsWithSiteContentCount(rCtx.PubIDStr)
}
}
videoAdUnitCtx = adunitconfig.UpdateVideoObjectWithAdunitConfig(rCtx, imp, div, payload.BidRequest.Device.ConnectionType)
bannerAdUnitCtx = adunitconfig.UpdateBannerObjectWithAdunitConfig(rCtx, imp, div)
}
Expand Down Expand Up @@ -215,9 +257,12 @@ func (m OpenWrap) handleBeforeValidationHook(
if err != nil || len(bidderParams) == 0 {
result.Errors = append(result.Errors, fmt.Sprintf("no bidder params found for imp:%s partner: %s", imp.ID, prebidBidderCode))
nonMapped[bidderCode] = struct{}{}
m.metricEngine.RecordSlotNotMappedErrorStats(rCtx.PubIDStr, bidderCode)
continue
}

m.metricEngine.RecordPlatformPublisherPartnerReqStats(rCtx.Platform, rCtx.PubIDStr, bidderCode)

bidderMeta[bidderCode] = models.PartnerData{
PartnerID: partnerID,
PrebidBidderCode: prebidBidderCode,
Expand Down Expand Up @@ -295,13 +340,15 @@ func (m OpenWrap) handleBeforeValidationHook(
result.NbrCode = nbr.AllSlotsDisabled
err = errors.New("All slots disabled: " + err.Error())
result.Errors = append(result.Errors, err.Error())
m.metricEngine.RecordNobidErrPrebidServerRequests(rCtx.PubIDStr)
return result, nil
}

if !serviceSideBidderPresent {
result.NbrCode = nbr.ServerSidePartnerNotConfigured
err = errors.New("server side partner not found: " + err.Error())
result.Errors = append(result.Errors, err.Error())
m.metricEngine.RecordNobidErrPrebidServerRequests(rCtx.PubIDStr)
return result, nil
}

Expand Down
2 changes: 2 additions & 0 deletions modules/pubmatic/openwrap/bidderparams/pubmatic.go
Expand Up @@ -88,6 +88,8 @@ func PreparePubMaticParamsV25(rctx models.RequestCtx, cache cache.Cache, bidRequ
extImpPubMatic.AdSlot = GenerateSlotName(0, 0, unmappedKPG, imp.TagID, div, rctx.Source)
if len(slots) != 0 { // reuse this field for wt and wl in combination with isRegex
matchedPattern = slots[0]
} else {
rctx.MetricsEngine.RecordMisConfigurationErrorStats(rctx.PubIDStr, string(openrtb_ext.BidderPubmatic))
}
}

Expand Down
8 changes: 7 additions & 1 deletion modules/pubmatic/openwrap/config/config.go
@@ -1,6 +1,10 @@
package config

import "time"
import (
"time"

"github.com/prebid/prebid-server/modules/pubmatic/openwrap/metrics/stats"
)

// Config contains the values read from the config file at boot time
type Config struct {
Expand All @@ -12,10 +16,12 @@ type Config struct {
PixelView PixelView
Features FeatureToggle
Log Log
Stats stats.Stats
}

type Server struct {
HostName string
DCName string //Name of the data center
}

type Database struct {
Expand Down

0 comments on commit 4deddf6

Please sign in to comment.