From 9bd3c1a31fa2b4ed6f70d5f78d7de837c7f5fab2 Mon Sep 17 00:00:00 2001 From: Pubmatic-Supriya-Patil <131644110+Pubmatic-Supriya-Patil@users.noreply.github.com> Date: Mon, 29 May 2023 12:45:31 +0530 Subject: [PATCH] Update ci with latest master (#494) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * OTT-1058: record number of deal responses for given pub-prof-partner (#485) (#487) Co-authored-by: Pubmatic-Dhruv-Sonone <83747371+Pubmatic-Dhruv-Sonone@users.noreply.github.com> * OTT-1060: Added IncDealBidCount in stats server for selected publishe… (#491) --------- Co-authored-by: ashishshinde-pubm <109787960+ashishshinde-pubm@users.noreply.github.com> Co-authored-by: Pubmatic-Dhruv-Sonone <83747371+Pubmatic-Dhruv-Sonone@users.noreply.github.com> Co-authored-by: ShriprasadM --- exchange/bidder.go | 4 +++- exchange/exchange_ow.go | 11 +++++++++++ metrics/pubmatic_stats/stats.go | 11 +++++++++++ metrics/pubmatic_stats/stats_test.go | 11 +++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 metrics/pubmatic_stats/stats.go create mode 100644 metrics/pubmatic_stats/stats_test.go diff --git a/exchange/bidder.go b/exchange/bidder.go index 178216cfe3c..fb8d4d8cfcc 100644 --- a/exchange/bidder.go +++ b/exchange/bidder.go @@ -389,6 +389,9 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, bidderRequest Bidde } } else { errs = append(errs, httpInfo.err) + if errortypes.ReadCode(httpInfo.err) == errortypes.TimeoutErrorCode { + recordPartnerTimeout(ctx, bidderRequest.BidderLabels.PubID, bidder.BidderName.String()) + } } } @@ -562,7 +565,6 @@ func (bidder *bidderAdapter) doRequestImpl(ctx context.Context, req *adapters.Re // a loop of trying to report timeouts to the timeout notifications. go bidder.doTimeoutNotification(tb, req, logger) } - } return &httpCallInfo{ request: req, diff --git a/exchange/exchange_ow.go b/exchange/exchange_ow.go index 786e1dbd18c..c4c7d232f71 100644 --- a/exchange/exchange_ow.go +++ b/exchange/exchange_ow.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/analytics" "github.com/prebid/prebid-server/exchange/entities" "github.com/prebid/prebid-server/metrics" + pubmaticstats "github.com/prebid/prebid-server/metrics/pubmatic_stats" "github.com/prebid/prebid-server/openrtb_ext" "golang.org/x/net/publicsuffix" ) @@ -176,9 +177,19 @@ func recordBids(ctx context.Context, metricsEngine metrics.MetricsEngine, pubID deal = nodeal } metricsEngine.RecordBids(pubID, profileID, seatBid.Seat, deal) + pubmaticstats.IncBidResponseByDealCountInPBS(pubID, profileID, seatBid.Seat, deal) } } } } } + +// recordPartnerTimeout captures the partnertimeout if any at publisher profile level +func recordPartnerTimeout(ctx context.Context, pubID, aliasBidder string) { + if metricEnabled, ok := ctx.Value(bidCountMetricEnabled).(bool); metricEnabled && ok { + if profileID, ok := ctx.Value(owProfileId).(string); ok && profileID != "" { + pubmaticstats.IncPartnerTimeoutInPBS(pubID, profileID, aliasBidder) + } + } +} diff --git a/metrics/pubmatic_stats/stats.go b/metrics/pubmatic_stats/stats.go new file mode 100644 index 00000000000..c9a113178b5 --- /dev/null +++ b/metrics/pubmatic_stats/stats.go @@ -0,0 +1,11 @@ +package pubmaticstats + +// IncBidResponseByDealCountInPBS counts number of bids received from aliasBidder for +// publisher, profile +// if dealid is not present then value would be'nodeal' +var IncBidResponseByDealCountInPBS = func(publisher, profile, aliasBidder, dealId string) { +} + +// IncPartnerTimeoutInPBS counts partner timeouts fro given publisher, profile and aliasbidder +var IncPartnerTimeoutInPBS = func(publisher, profile, aliasBidder string) { +} diff --git a/metrics/pubmatic_stats/stats_test.go b/metrics/pubmatic_stats/stats_test.go new file mode 100644 index 00000000000..cb3fe918246 --- /dev/null +++ b/metrics/pubmatic_stats/stats_test.go @@ -0,0 +1,11 @@ +package pubmaticstats + +import "testing" + +func TestIncBidResponseByDealCountInPBS(t *testing.T) { + IncBidResponseByDealCountInPBS("some_publisher_id", "some_profile_id", "some_alias_bidder", "some_dealid") +} + +func TestIncPartnerTimeoutInPBS(t *testing.T) { + IncPartnerTimeoutInPBS("some_publisher_id", "some_profile_id", "some_alias_bidder") +}