Skip to content

Commit

Permalink
OTT-1726 enable analytics throttling for amp and modules 2.5 endpoint (
Browse files Browse the repository at this point in the history
…#779)

Co-authored-by: Viral Vala <[email protected]>
  • Loading branch information
pm-nikhil-vaidya and pm-viral-vala authored May 2, 2024
1 parent 7ad739b commit cb8ef8a
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 53 deletions.
4 changes: 2 additions & 2 deletions endpoints/openrtb2/auction_ow.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func UpdateResponseExtOW(bidResponse *openrtb2.BidResponse, ao analytics.Auction
}
}

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

Expand All @@ -72,7 +72,7 @@ func UpdateResponseExtOW(bidResponse *openrtb2.BidResponse, ao analytics.Auction
// extBidResponse.Prebid.SeatNonBid = seatNonBids
// }

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

Expand Down
13 changes: 13 additions & 0 deletions modules/pubmatic/openwrap/beforevalidationhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (m OpenWrap) handleBeforeValidationHook(
rCtx.NewReqExt = requestExt
rCtx.CustomDimensions = customdimensions.GetCustomDimensions(requestExt.Prebid.BidderParams)
rCtx.ReturnAllBidStatus = requestExt.Prebid.ReturnAllBidStatus
m.setAnanlyticsFlags(&rCtx)

// TODO: verify preference of request.test vs queryParam test ++ this check is only for the CTV requests
if payload.BidRequest.Test != 0 {
Expand Down Expand Up @@ -931,6 +932,18 @@ func getTagID(imp openrtb2.Imp, impExt *models.ImpExtension) string {
return impExt.Data.PbAdslot
}

func (m OpenWrap) setAnanlyticsFlags(rCtx *models.RequestCtx) {
rCtx.LoggerDisabled, rCtx.TrackerDisabled = m.pubFeatures.IsAnalyticsTrackingThrottled(rCtx.PubID, rCtx.ProfileID)

if rCtx.LoggerDisabled {
rCtx.MetricsEngine.RecordAnalyticsTrackingThrottled(strconv.Itoa(rCtx.PubID), strconv.Itoa(rCtx.ProfileID), models.AnanlyticsThrottlingLoggerType)
}

if rCtx.TrackerDisabled {
rCtx.MetricsEngine.RecordAnalyticsTrackingThrottled(strconv.Itoa(rCtx.PubID), strconv.Itoa(rCtx.ProfileID), models.AnanlyticsThrottlingTrackerType)
}
}

func updateImpVideoWithVideoConfig(imp *openrtb2.Imp, configObjInVideoConfig *modelsAdunitConfig.VideoConfig) {

if len(imp.Video.MIMEs) == 0 {
Expand Down
33 changes: 23 additions & 10 deletions modules/pubmatic/openwrap/beforevalidationhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordPublisherInvalidProfileRequests(rctx.Endpoint, "5890", rctx.ProfileIDStr)
mockEngine.EXPECT().RecordPublisherInvalidProfileImpressions("5890", rctx.ProfileIDStr, gomock.Any())
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)

mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2345,7 +2345,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordPublisherInvalidProfileRequests(rctx.Endpoint, "5890", rctx.ProfileIDStr)
mockEngine.EXPECT().RecordPublisherInvalidProfileImpressions("5890", rctx.ProfileIDStr, gomock.Any())
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)

mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2390,7 +2390,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordPublisherInvalidProfileRequests(rctx.Endpoint, "5890", rctx.ProfileIDStr)
mockEngine.EXPECT().RecordPublisherInvalidProfileImpressions("5890", rctx.ProfileIDStr, gomock.Any())
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)

mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2436,6 +2436,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordNobidErrPrebidServerRequests("5890", int(nbr.AllPartnerThrottled))
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2481,6 +2482,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordNobidErrPrebidServerRequests("5890", int(nbr.InvalidImpressionTagID))
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2530,6 +2532,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordNobidErrPrebidServerRequests("5890", int(nbr.InvalidImpressionTagID))
mockEngine.EXPECT().RecordPublisherRequests(models.EndpointWebS2S, "5890", rctx.Platform)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2575,6 +2578,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordNobidErrPrebidServerRequests("5890", int(nbr.InternalError))
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2664,6 +2668,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordImpDisabledViaConfigStats(models.ImpTypeVideo, "5890", "1234")
mockEngine.EXPECT().RecordImpDisabledViaConfigStats(models.ImpTypeBanner, "5890", "1234")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2767,6 +2772,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordImpDisabledViaConfigStats(models.ImpTypeVideo, "5890", "1234")
mockEngine.EXPECT().RecordImpDisabledViaConfigStats(models.ImpTypeBanner, "5890", "1234")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: false,
Expand Down Expand Up @@ -2844,7 +2850,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordNobidErrPrebidServerRequests("5890", int(nbr.ServerSidePartnerNotConfigured))
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)

mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: true,
Expand Down Expand Up @@ -2955,6 +2961,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "appnexus")
mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "dm-alias")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: false,
Expand Down Expand Up @@ -3046,6 +3053,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "appnexus")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: false,
Expand Down Expand Up @@ -3206,6 +3214,7 @@ func TestOpenWrapHandleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats("amp", "5890", "appnexus")
mockFeature.EXPECT().IsAmpMultiformatEnabled(5890).Return(true)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: hookstage.HookResult[hookstage.BeforeValidationRequestPayload]{
Reject: false,
Expand Down Expand Up @@ -3459,11 +3468,11 @@ func TestVASTUnwrap_handleBeforeValidationHook(t *testing.T) {
},
}, nil)
mockCache.EXPECT().GetAdunitConfigFromCache(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&adunitconfig.AdUnitConfig{})

mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "appnexus")
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockEngine.EXPECT().RecordPublisherProfileRequests("5890", "1234")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down Expand Up @@ -3520,11 +3529,11 @@ func TestVASTUnwrap_handleBeforeValidationHook(t *testing.T) {
},
}, nil)
mockCache.EXPECT().GetAdunitConfigFromCache(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&adunitconfig.AdUnitConfig{})

mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "appnexus")
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockEngine.EXPECT().RecordPublisherProfileRequests("5890", "1234")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down Expand Up @@ -3586,11 +3595,11 @@ func TestVASTUnwrap_handleBeforeValidationHook(t *testing.T) {
},
}, nil)
mockCache.EXPECT().GetAdunitConfigFromCache(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&adunitconfig.AdUnitConfig{})

mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "appnexus")
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockEngine.EXPECT().RecordPublisherProfileRequests("5890", "1234")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down Expand Up @@ -3653,11 +3662,11 @@ func TestVASTUnwrap_handleBeforeValidationHook(t *testing.T) {
},
}, nil)
mockCache.EXPECT().GetAdunitConfigFromCache(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&adunitconfig.AdUnitConfig{})

mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "appnexus")
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockEngine.EXPECT().RecordPublisherProfileRequests("5890", "1234")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down Expand Up @@ -3715,11 +3724,11 @@ func TestVASTUnwrap_handleBeforeValidationHook(t *testing.T) {
},
}, nil)
mockCache.EXPECT().GetAdunitConfigFromCache(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&adunitconfig.AdUnitConfig{})

mockEngine.EXPECT().RecordPlatformPublisherPartnerReqStats(rctx.Platform, "5890", "appnexus")
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockEngine.EXPECT().RecordPublisherProfileRequests("5890", "1234")
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down Expand Up @@ -3821,6 +3830,7 @@ func TestImpBidCtx_handleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordPublisherInvalidProfileRequests(rctx.Endpoint, "5890", rctx.ProfileIDStr)
mockEngine.EXPECT().RecordPublisherInvalidProfileImpressions("5890", rctx.ProfileIDStr, gomock.Any())
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down Expand Up @@ -3873,7 +3883,7 @@ func TestImpBidCtx_handleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordPublisherInvalidProfileRequests(rctx.Endpoint, "5890", rctx.ProfileIDStr)
mockEngine.EXPECT().RecordPublisherInvalidProfileImpressions("5890", rctx.ProfileIDStr, gomock.Any())
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)

mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down Expand Up @@ -3927,6 +3937,7 @@ func TestImpBidCtx_handleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordNobidErrPrebidServerRequests("5890", int(nbr.AllPartnerThrottled))
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
error: false,
Expand Down Expand Up @@ -3980,6 +3991,7 @@ func TestImpBidCtx_handleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordNobidErrPrebidServerRequests("5890", int(nbr.InvalidImpressionTagID))
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down Expand Up @@ -4025,6 +4037,7 @@ func TestImpBidCtx_handleBeforeValidationHook(t *testing.T) {
mockEngine.EXPECT().RecordNobidErrPrebidServerRequests("5890", int(nbr.InternalError))
mockEngine.EXPECT().RecordPublisherRequests(rctx.Endpoint, "5890", rctx.Platform)
mockFeature.EXPECT().IsTBFFeatureEnabled(gomock.Any(), gomock.Any()).Return(false)
mockFeature.EXPECT().IsAnalyticsTrackingThrottled(gomock.Any(), gomock.Any()).Return(false, false)
},
want: want{
rctx: &models.RequestCtx{
Expand Down
7 changes: 6 additions & 1 deletion modules/pubmatic/openwrap/database/mysql/adunit_config.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package mysql

import (
"context"
"database/sql"
"encoding/json"
"strconv"
"strings"
"time"

"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/models"
"github.com/prebid/prebid-server/v2/modules/pubmatic/openwrap/models/adunitconfig"
Expand All @@ -19,8 +21,11 @@ func (db *mySqlDB) GetAdunitConfig(profileID, displayVersion int) (*adunitconfig
adunitConfigQuery = strings.Replace(adunitConfigQuery, profileIdKey, strconv.Itoa(profileID), -1)
adunitConfigQuery = strings.Replace(adunitConfigQuery, displayVersionKey, strconv.Itoa(displayVersion), -1)

ctx, cancel := context.WithTimeout(context.Background(), time.Duration(time.Millisecond*time.Duration(db.cfg.MaxDbContextTimeout)))
defer cancel()

var adunitConfigJSON string
err := db.conn.QueryRow(adunitConfigQuery).Scan(&adunitConfigJSON)
err := db.conn.QueryRowContext(ctx, adunitConfigQuery).Scan(&adunitConfigJSON)
if err != nil {
if err == sql.ErrNoRows {
return nil, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func Test_mySqlDB_GetAdunitConfig(t *testing.T) {
Queries: config.Queries{
GetAdunitConfigForLiveVersion: "^SELECT (.+) FROM wrapper_media_config (.+) LIVE",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand All @@ -72,6 +73,7 @@ func Test_mySqlDB_GetAdunitConfig(t *testing.T) {
Queries: config.Queries{
GetAdunitConfigForLiveVersion: "^SELECT (.+) FROM wrapper_media_config (.+) LIVE",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand Down Expand Up @@ -102,6 +104,7 @@ func Test_mySqlDB_GetAdunitConfig(t *testing.T) {
Queries: config.Queries{
GetAdunitConfigQuery: "^SELECT (.+) FROM wrapper_media_config (.+)",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand Down Expand Up @@ -132,6 +135,7 @@ func Test_mySqlDB_GetAdunitConfig(t *testing.T) {
Queries: config.Queries{
GetAdunitConfigForLiveVersion: "^SELECT (.+) FROM wrapper_media_config (.+) LIVE",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand All @@ -157,6 +161,7 @@ func Test_mySqlDB_GetAdunitConfig(t *testing.T) {
Queries: config.Queries{
GetAdunitConfigQuery: "^SELECT (.+) FROM wrapper_media_config (.+)",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand Down Expand Up @@ -187,6 +192,7 @@ func Test_mySqlDB_GetAdunitConfig(t *testing.T) {
Queries: config.Queries{
GetAdunitConfigQuery: "^SELECT (.+) FROM wrapper_media_config (.+)",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand Down Expand Up @@ -218,6 +224,7 @@ func Test_mySqlDB_GetAdunitConfig(t *testing.T) {
Queries: config.Queries{
GetAdunitConfigQuery: "^SELECT (.+) FROM wrapper_media_config (.+)",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package mysql

import (
"context"
"strconv"
"time"

"github.com/golang/glog"
)

func (db *mySqlDB) GetFSCThresholdPerDSP() (map[int]int, error) {
rows, err := db.conn.Query(db.cfg.Queries.GetAllDspFscPcntQuery)
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(time.Millisecond*time.Duration(db.cfg.MaxDbContextTimeout)))
defer cancel()

rows, err := db.conn.QueryContext(ctx, db.cfg.Queries.GetAllDspFscPcntQuery)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func Test_mySqlDB_GetFSCThresholdPerDSP(t *testing.T) {
Queries: config.Queries{
GetAllDspFscPcntQuery: "^SELECT (.+) FROM wrapper_feature_dsp_mapping (.+)",
},
MaxDbContextTimeout: 1000,
},
},
want: map[int]int{},
Expand All @@ -61,6 +62,7 @@ func Test_mySqlDB_GetFSCThresholdPerDSP(t *testing.T) {
Queries: config.Queries{
GetAllDspFscPcntQuery: "^SELECT (.+) FROM wrapper_feature_dsp_mapping (.+)",
},
MaxDbContextTimeout: 1000,
},
},
want: map[int]int{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func Test_mySqlDB_GetActivePartnerConfigurations(t *testing.T) {
Queries: config.Queries{
LiveVersionInnerQuery: "^SELECT (.+) FROM wrapper_version (.+) LIVE",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand Down Expand Up @@ -63,6 +64,7 @@ func Test_mySqlDB_GetActivePartnerConfigurations(t *testing.T) {
Queries: config.Queries{
LiveVersionInnerQuery: "^SELECT (.+) FROM wrapper_version (.+) LIVE",
},
MaxDbContextTimeout: 1000,
},
},
args: args{
Expand Down
Loading

0 comments on commit cb8ef8a

Please sign in to comment.