From a40df30fd86bb296873ec64a737729e95c1c1757 Mon Sep 17 00:00:00 2001 From: Scott Kay Date: Tue, 9 Apr 2024 18:06:23 -0400 Subject: [PATCH 1/2] Rename Blacklisted Apps to Blocked Apps --- config/config.go | 17 ++++++++--------- config/config_test.go | 12 ++++++------ endpoints/events/event.go | 2 +- endpoints/openrtb2/amp_auction.go | 4 ++-- endpoints/openrtb2/amp_auction_test.go | 4 ++-- endpoints/openrtb2/auction.go | 8 ++++---- endpoints/openrtb2/auction_benchmark_test.go | 4 ++-- endpoints/openrtb2/auction_test.go | 8 ++++---- .../blocked-app.json} | 4 ++-- endpoints/openrtb2/test_utils.go | 16 ++++++++-------- endpoints/openrtb2/video_auction.go | 8 ++++---- endpoints/openrtb2/video_auction_test.go | 6 +++--- errortypes/code.go | 2 +- errortypes/errortypes.go | 15 ++++++--------- metrics/config/metrics_test.go | 14 +++++++------- metrics/metrics.go | 4 ++-- metrics/prometheus/prometheus_test.go | 6 +++--- 17 files changed, 65 insertions(+), 69 deletions(-) rename endpoints/openrtb2/sample-requests/{blacklisted/blacklisted-app.json => blocked/blocked-app.json} (96%) diff --git a/config/config.go b/config/config.go index 86521c4c36c..95755e3e76e 100644 --- a/config/config.go +++ b/config/config.go @@ -66,9 +66,9 @@ type Configuration struct { VideoStoredRequestRequired bool `mapstructure:"video_stored_request_required"` - // Array of blacklisted apps that is used to create the hash table BlacklistedAppMap so App.ID's can be instantly accessed. - BlacklistedApps []string `mapstructure:"blacklisted_apps,flow"` - BlacklistedAppMap map[string]bool + // Array of blocked apps that is used to create the hash table BlockedAppsLookup so App.ID's can be instantly accessed. + BlockedApps []string `mapstructure:"blocked_apps,flow"` + BlockedAppsLookup map[string]bool // Is publisher/account ID required to be submitted in the OpenRTB2 request AccountRequired bool `mapstructure:"account_required"` // AccountDefaults defines default settings for valid accounts that are partially defined @@ -788,10 +788,10 @@ func New(v *viper.Viper, bidderInfos BidderInfos, normalizeBidderName func(strin } // To look for a request's app_id in O(1) time, we fill this hash table located in the - // the BlacklistedApps field of the Configuration struct defined in this file - c.BlacklistedAppMap = make(map[string]bool) - for i := 0; i < len(c.BlacklistedApps); i++ { - c.BlacklistedAppMap[c.BlacklistedApps[i]] = true + // the BlockedApps field of the Configuration struct defined in this file + c.BlockedAppsLookup = make(map[string]bool) + for i := 0; i < len(c.BlockedApps); i++ { + c.BlockedAppsLookup[c.BlockedApps[i]] = true } // Migrate combo stored request config to separate stored_reqs and amp stored_reqs configs. @@ -1138,8 +1138,7 @@ func SetupViper(v *viper.Viper, filename string, bidderInfos BidderInfos) { v.SetDefault("default_request.type", "") v.SetDefault("default_request.file.name", "") v.SetDefault("default_request.alias_info", false) - v.SetDefault("blacklisted_apps", []string{""}) - v.SetDefault("blacklisted_accts", []string{""}) + v.SetDefault("blocked_apps", []string{""}) v.SetDefault("account_required", false) v.SetDefault("account_defaults.disabled", false) v.SetDefault("account_defaults.debug_allow", true) diff --git a/config/config_test.go b/config/config_test.go index 4c97f125997..b4de7bc6e98 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -447,7 +447,7 @@ metrics: adapter_connections_metrics: true adapter_gdpr_request_blocked: true account_modules_metrics: true -blacklisted_apps: ["spamAppID","sketchy-app-id"] +blocked_apps: ["spamAppID","sketchy-app-id"] account_required: true auto_gen_source_tid: false certificates_file: /etc/ssl/cert.pem @@ -709,12 +709,12 @@ func TestFullConfig(t *testing.T) { cmpBools(t, "lmt.enforce", true, cfg.LMT.Enforce) //Assert the NonStandardPublishers was correctly unmarshalled - cmpStrings(t, "blacklisted_apps", "spamAppID", cfg.BlacklistedApps[0]) - cmpStrings(t, "blacklisted_apps", "sketchy-app-id", cfg.BlacklistedApps[1]) + cmpStrings(t, "blocked_apps", "spamAppID", cfg.BlockedApps[0]) + cmpStrings(t, "blocked_apps", "sketchy-app-id", cfg.BlockedApps[1]) - //Assert the BlacklistedAppMap hash table was built correctly - for i := 0; i < len(cfg.BlacklistedApps); i++ { - cmpBools(t, "cfg.BlacklistedAppMap", true, cfg.BlacklistedAppMap[cfg.BlacklistedApps[i]]) + //Assert the BlockedAppsLookup hash table was built correctly + for i := 0; i < len(cfg.BlockedApps); i++ { + cmpBools(t, "cfg.BlockedAppsLookup", true, cfg.BlockedAppsLookup[cfg.BlockedApps[i]]) } //Assert purpose VendorExceptionMap hash tables were built correctly diff --git a/endpoints/events/event.go b/endpoints/events/event.go index e202932aff8..415f529eaa7 100644 --- a/endpoints/events/event.go +++ b/endpoints/events/event.go @@ -216,7 +216,7 @@ func HandleAccountServiceErrors(errs []error) (status int, messages []string) { errCode := errortypes.ReadCode(er) - if errCode == errortypes.BlacklistedAppErrorCode || errCode == errortypes.AccountDisabledErrorCode { + if errCode == errortypes.BlockedAppErrorCode || errCode == errortypes.AccountDisabledErrorCode { status = http.StatusServiceUnavailable } if errCode == errortypes.MalformedAcctErrorCode { diff --git a/endpoints/openrtb2/amp_auction.go b/endpoints/openrtb2/amp_auction.go index 4a6574e8421..41f8242dffa 100644 --- a/endpoints/openrtb2/amp_auction.go +++ b/endpoints/openrtb2/amp_auction.go @@ -211,9 +211,9 @@ func (deps *endpointDeps) AmpAuction(w http.ResponseWriter, r *http.Request, _ h metricsStatus := metrics.RequestStatusBadInput for _, er := range errL { errCode := errortypes.ReadCode(er) - if errCode == errortypes.BlacklistedAppErrorCode || errCode == errortypes.AccountDisabledErrorCode { + if errCode == errortypes.BlockedAppErrorCode || errCode == errortypes.AccountDisabledErrorCode { httpStatus = http.StatusServiceUnavailable - metricsStatus = metrics.RequestStatusBlacklisted + metricsStatus = metrics.RequestStatusBlockedApp break } if errCode == errortypes.MalformedAcctErrorCode { diff --git a/endpoints/openrtb2/amp_auction_test.go b/endpoints/openrtb2/amp_auction_test.go index 6e6e1ac855e..a056b73b0fe 100644 --- a/endpoints/openrtb2/amp_auction_test.go +++ b/endpoints/openrtb2/amp_auction_test.go @@ -102,8 +102,8 @@ func TestGoodAmpRequests(t *testing.T) { GDPR: config.GDPR{Enabled: true}, } if test.Config != nil { - cfg.BlacklistedApps = test.Config.BlacklistedApps - cfg.BlacklistedAppMap = test.Config.getBlacklistedAppMap() + cfg.BlockedApps = test.Config.BlockedApps + cfg.BlockedAppsLookup = test.Config.getBlockedAppLookup() cfg.AccountRequired = test.Config.AccountRequired } diff --git a/endpoints/openrtb2/auction.go b/endpoints/openrtb2/auction.go index 8c178ff3c0b..9933ba44172 100644 --- a/endpoints/openrtb2/auction.go +++ b/endpoints/openrtb2/auction.go @@ -1787,8 +1787,8 @@ func (deps *endpointDeps) validateApp(req *openrtb_ext.RequestWrapper) error { } if req.App.ID != "" { - if _, found := deps.cfg.BlacklistedAppMap[req.App.ID]; found { - return &errortypes.BlacklistedApp{Message: fmt.Sprintf("Prebid-server does not process requests from App ID: %s", req.App.ID)} + if _, found := deps.cfg.BlockedAppsLookup[req.App.ID]; found { + return &errortypes.BlockedApp{Message: fmt.Sprintf("Prebid-server does not process requests from App ID: %s", req.App.ID)} } } @@ -2431,9 +2431,9 @@ func writeError(errs []error, w http.ResponseWriter, labels *metrics.Labels) boo metricsStatus := metrics.RequestStatusBadInput for _, err := range errs { erVal := errortypes.ReadCode(err) - if erVal == errortypes.BlacklistedAppErrorCode || erVal == errortypes.AccountDisabledErrorCode { + if erVal == errortypes.BlockedAppErrorCode || erVal == errortypes.AccountDisabledErrorCode { httpStatus = http.StatusServiceUnavailable - metricsStatus = metrics.RequestStatusBlacklisted + metricsStatus = metrics.RequestStatusBlockedApp break } else if erVal == errortypes.MalformedAcctErrorCode { httpStatus = http.StatusInternalServerError diff --git a/endpoints/openrtb2/auction_benchmark_test.go b/endpoints/openrtb2/auction_benchmark_test.go index 835d2920af4..b4bdfbbbf21 100644 --- a/endpoints/openrtb2/auction_benchmark_test.go +++ b/endpoints/openrtb2/auction_benchmark_test.go @@ -149,8 +149,8 @@ func BenchmarkValidWholeExemplary(b *testing.B) { cfg := &config.Configuration{ MaxRequestSize: maxSize, - BlacklistedApps: test.Config.BlacklistedApps, - BlacklistedAppMap: test.Config.getBlacklistedAppMap(), + BlockedApps: test.Config.BlockedApps, + BlockedAppsLookup: test.Config.getBlockedAppLookup(), AccountRequired: test.Config.AccountRequired, } diff --git a/endpoints/openrtb2/auction_test.go b/endpoints/openrtb2/auction_test.go index af6f4a1b86a..67fcffe1933 100644 --- a/endpoints/openrtb2/auction_test.go +++ b/endpoints/openrtb2/auction_test.go @@ -80,8 +80,8 @@ func TestJsonSampleRequests(t *testing.T) { "account-malformed", }, { - "Asserts we return 503s on requests with blacklisted accounts and apps.", - "blacklisted", + "Asserts we return 503s on requests with blocked apps.", + "blocked", }, { "Assert that requests that come with no user id nor app id return error if the `AccountRequired` field in the `config.Configuration` structure is set to true", @@ -166,8 +166,8 @@ func runJsonBasedTest(t *testing.T, filename, desc string) { // Build endpoint for testing. If no error, run test case cfg := &config.Configuration{MaxRequestSize: maxSize} if test.Config != nil { - cfg.BlacklistedApps = test.Config.BlacklistedApps - cfg.BlacklistedAppMap = test.Config.getBlacklistedAppMap() + cfg.BlockedApps = test.Config.BlockedApps + cfg.BlockedAppsLookup = test.Config.getBlockedAppLookup() cfg.AccountRequired = test.Config.AccountRequired } cfg.MarshalAccountDefaults() diff --git a/endpoints/openrtb2/sample-requests/blacklisted/blacklisted-app.json b/endpoints/openrtb2/sample-requests/blocked/blocked-app.json similarity index 96% rename from endpoints/openrtb2/sample-requests/blacklisted/blacklisted-app.json rename to endpoints/openrtb2/sample-requests/blocked/blocked-app.json index 120fcec08f4..88e0ed43496 100644 --- a/endpoints/openrtb2/sample-requests/blacklisted/blacklisted-app.json +++ b/endpoints/openrtb2/sample-requests/blocked/blocked-app.json @@ -1,7 +1,7 @@ { - "description": "This is a perfectly valid request except that it comes from a blacklisted App", + "description": "This is a perfectly valid request except that it comes from a blocked app", "config": { - "blacklistedApps": ["spam_app"] + "blockedApps": ["spam_app"] }, "mockBidRequest": { "id": "some-request-id", diff --git a/endpoints/openrtb2/test_utils.go b/endpoints/openrtb2/test_utils.go index 6fedb73cd47..72876a019b7 100644 --- a/endpoints/openrtb2/test_utils.go +++ b/endpoints/openrtb2/test_utils.go @@ -85,7 +85,7 @@ type testCase struct { type testConfigValues struct { AccountRequired bool `json:"accountRequired"` AliasJSON string `json:"aliases"` - BlacklistedApps []string `json:"blacklistedApps"` + BlockedApps []string `json:"blockedApps"` DisabledAdapters []string `json:"disabledAdapters"` CurrencyRates map[string]map[string]float64 `json:"currencyRates"` MockBidders []mockBidderHandler `json:"mockBidders"` @@ -1140,16 +1140,16 @@ func parseTestData(fileData []byte, testFile string) (testCase, error) { return parsedTestData, nil } -func (tc *testConfigValues) getBlacklistedAppMap() map[string]bool { - var blacklistedAppMap map[string]bool +func (tc *testConfigValues) getBlockedAppLookup() map[string]bool { + var blockedAppLookup map[string]bool - if len(tc.BlacklistedApps) > 0 { - blacklistedAppMap = make(map[string]bool, len(tc.BlacklistedApps)) - for _, app := range tc.BlacklistedApps { - blacklistedAppMap[app] = true + if len(tc.BlockedApps) > 0 { + blockedAppLookup = make(map[string]bool, len(tc.BlockedApps)) + for _, app := range tc.BlockedApps { + blockedAppLookup[app] = true } } - return blacklistedAppMap + return blockedAppLookup } // exchangeTestWrapper is a wrapper that asserts the openrtb2 bid request just before the HoldAuction call diff --git a/endpoints/openrtb2/video_auction.go b/endpoints/openrtb2/video_auction.go index f74a4a224ae..efb2d86ce5d 100644 --- a/endpoints/openrtb2/video_auction.go +++ b/endpoints/openrtb2/video_auction.go @@ -411,9 +411,9 @@ func handleError(labels *metrics.Labels, w http.ResponseWriter, errL []error, vo var status int = http.StatusInternalServerError for _, er := range errL { erVal := errortypes.ReadCode(er) - if erVal == errortypes.BlacklistedAppErrorCode || erVal == errortypes.AccountDisabledErrorCode { + if erVal == errortypes.BlockedAppErrorCode || erVal == errortypes.AccountDisabledErrorCode { status = http.StatusServiceUnavailable - labels.RequestStatus = metrics.RequestStatusBlacklisted + labels.RequestStatus = metrics.RequestStatusBlockedApp break } else if erVal == errortypes.AcctRequiredErrorCode { status = http.StatusBadRequest @@ -813,8 +813,8 @@ func (deps *endpointDeps) validateVideoRequest(req *openrtb_ext.BidRequestVideo) errL = append(errL, err) } else if req.App != nil { if req.App.ID != "" { - if _, found := deps.cfg.BlacklistedAppMap[req.App.ID]; found { - err := &errortypes.BlacklistedApp{Message: fmt.Sprintf("Prebid-server does not process requests from App ID: %s", req.App.ID)} + if _, found := deps.cfg.BlockedAppsLookup[req.App.ID]; found { + err := &errortypes.BlockedApp{Message: fmt.Sprintf("Prebid-server does not process requests from App ID: %s", req.App.ID)} errL = append(errL, err) return errL, podErrors } diff --git a/endpoints/openrtb2/video_auction_test.go b/endpoints/openrtb2/video_auction_test.go index cc522c91d25..7a226e98d57 100644 --- a/endpoints/openrtb2/video_auction_test.go +++ b/endpoints/openrtb2/video_auction_test.go @@ -813,15 +813,15 @@ func TestHandleError(t *testing.T) { &errortypes.AccountDisabled{}, }, wantCode: 503, - wantMetricsStatus: metrics.RequestStatusBlacklisted, + wantMetricsStatus: metrics.RequestStatusBlockedApp, }, { description: "Blocked app - return 503 with blocked metrics status", giveErrors: []error{ - &errortypes.BlacklistedApp{}, + &errortypes.BlockedApp{}, }, wantCode: 503, - wantMetricsStatus: metrics.RequestStatusBlacklisted, + wantMetricsStatus: metrics.RequestStatusBlockedApp, }, { description: "Account required error - return 400 with bad input metrics status", diff --git a/errortypes/code.go b/errortypes/code.go index a56df67c9c9..652a7a68f8a 100644 --- a/errortypes/code.go +++ b/errortypes/code.go @@ -5,7 +5,7 @@ const ( UnknownErrorCode = 999 TimeoutErrorCode = iota BadInputErrorCode - BlacklistedAppErrorCode + BlockedAppErrorCode BadServerResponseErrorCode FailedToRequestBidsErrorCode BidderTemporarilyDisabledErrorCode diff --git a/errortypes/errortypes.go b/errortypes/errortypes.go index 7ca5668c290..fe4eb8ae460 100644 --- a/errortypes/errortypes.go +++ b/errortypes/errortypes.go @@ -59,23 +59,20 @@ func (err *BadInput) Severity() Severity { return SeverityFatal } -// BlacklistedApp should be used when a request App.ID matches an entry in the BlacklistedApps -// environment variable array -// -// These errors will be written to http.ResponseWriter before canceling execution -type BlacklistedApp struct { +// BlockedApp should be used when a request App.ID matches an entry in the BlockedApp configuration. +type BlockedApp struct { Message string } -func (err *BlacklistedApp) Error() string { +func (err *BlockedApp) Error() string { return err.Message } -func (err *BlacklistedApp) Code() int { - return BlacklistedAppErrorCode +func (err *BlockedApp) Code() int { + return BlockedAppErrorCode } -func (err *BlacklistedApp) Severity() Severity { +func (err *BlockedApp) Severity() Severity { return SeverityFatal } diff --git a/metrics/config/metrics_test.go b/metrics/config/metrics_test.go index 5badc348e61..789b573cb85 100644 --- a/metrics/config/metrics_test.go +++ b/metrics/config/metrics_test.go @@ -109,23 +109,23 @@ func TestMultiMetricsEngine(t *testing.T) { metricsEngine.RecordModuleExecutionError(module) metricsEngine.RecordModuleTimeout(module) } - labelsBlacklist := []metrics.Labels{ + labelsBlocked := []metrics.Labels{ { Source: metrics.DemandWeb, RType: metrics.ReqTypeAMP, PubID: "test2", CookieFlag: metrics.CookieFlagYes, - RequestStatus: metrics.RequestStatusBlacklisted, + RequestStatus: metrics.RequestStatusBlockedApp, }, { Source: metrics.DemandWeb, RType: metrics.ReqTypeVideo, PubID: "test2", CookieFlag: metrics.CookieFlagYes, - RequestStatus: metrics.RequestStatusBlacklisted, + RequestStatus: metrics.RequestStatusBlockedApp, }, } - for _, label := range labelsBlacklist { + for _, label := range labelsBlocked { metricsEngine.RecordRequest(label) } impTypeLabels.BannerImps = false @@ -150,14 +150,14 @@ func TestMultiMetricsEngine(t *testing.T) { //Make the metrics engine, instantiated here with goEngine, fill its RequestStatuses[RequestType][metrics.RequestStatusXX] with the new boolean values added to metrics.Labels VerifyMetrics(t, "RequestStatuses.OpenRTB2.OK", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusOK].Count(), 5) VerifyMetrics(t, "RequestStatuses.AMP.OK", goEngine.RequestStatuses[metrics.ReqTypeAMP][metrics.RequestStatusOK].Count(), 0) - VerifyMetrics(t, "RequestStatuses.AMP.BlacklistedAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeAMP][metrics.RequestStatusBlacklisted].Count(), 1) + VerifyMetrics(t, "RequestStatuses.AMP.BlockedAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeAMP][metrics.RequestStatusBlockedApp].Count(), 1) VerifyMetrics(t, "RequestStatuses.Video.OK", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusOK].Count(), 0) VerifyMetrics(t, "RequestStatuses.Video.Error", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusErr].Count(), 0) VerifyMetrics(t, "RequestStatuses.Video.BadInput", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusBadInput].Count(), 0) - VerifyMetrics(t, "RequestStatuses.Video.BlacklistedAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusBlacklisted].Count(), 1) + VerifyMetrics(t, "RequestStatuses.Video.BlockededAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusBlockedApp].Count(), 1) VerifyMetrics(t, "RequestStatuses.OpenRTB2.Error", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusErr].Count(), 0) VerifyMetrics(t, "RequestStatuses.OpenRTB2.BadInput", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusBadInput].Count(), 0) - VerifyMetrics(t, "RequestStatuses.OpenRTB2.BlacklistedAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusBlacklisted].Count(), 0) + VerifyMetrics(t, "RequestStatuses.OpenRTB2.BlockedAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusBlockedApp].Count(), 0) VerifyMetrics(t, "ImpsTypeBanner", goEngine.ImpsTypeBanner.Count(), 5) VerifyMetrics(t, "ImpsTypeVideo", goEngine.ImpsTypeVideo.Count(), 3) diff --git a/metrics/metrics.go b/metrics/metrics.go index 7d3dc819341..3f0bc083e29 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -234,7 +234,7 @@ const ( RequestStatusBadInput RequestStatus = "badinput" RequestStatusErr RequestStatus = "err" RequestStatusNetworkErr RequestStatus = "networkerr" - RequestStatusBlacklisted RequestStatus = "blacklistedacctorapp" + RequestStatusBlockedApp RequestStatus = "blockedapp" RequestStatusQueueTimeout RequestStatus = "queuetimeout" RequestStatusAccountConfigErr RequestStatus = "acctconfigerr" ) @@ -245,7 +245,7 @@ func RequestStatuses() []RequestStatus { RequestStatusBadInput, RequestStatusErr, RequestStatusNetworkErr, - RequestStatusBlacklisted, + RequestStatusBlockedApp, RequestStatusQueueTimeout, RequestStatusAccountConfigErr, } diff --git a/metrics/prometheus/prometheus_test.go b/metrics/prometheus/prometheus_test.go index a74c8b6c0fa..839cdc0f9e9 100644 --- a/metrics/prometheus/prometheus_test.go +++ b/metrics/prometheus/prometheus_test.go @@ -141,7 +141,7 @@ func TestConnectionMetrics(t *testing.T) { func TestRequestMetric(t *testing.T) { m := createMetricsForTesting() requestType := metrics.ReqTypeORTB2Web - requestStatus := metrics.RequestStatusBlacklisted + requestStatus := metrics.RequestStatusBlockedApp m.RecordRequest(metrics.Labels{ RType: requestType, @@ -285,7 +285,7 @@ func TestRequestMetricWithoutCookie(t *testing.T) { performTest := func(m *Metrics, cookieFlag metrics.CookieFlag) { m.RecordRequest(metrics.Labels{ RType: requestType, - RequestStatus: metrics.RequestStatusBlacklisted, + RequestStatus: metrics.RequestStatusBlockedApp, CookieFlag: cookieFlag, }) } @@ -337,7 +337,7 @@ func TestAccountMetric(t *testing.T) { performTest := func(m *Metrics, pubID string) { m.RecordRequest(metrics.Labels{ RType: metrics.ReqTypeORTB2Web, - RequestStatus: metrics.RequestStatusBlacklisted, + RequestStatus: metrics.RequestStatusBlockedApp, PubID: pubID, }) } From 9b54147e23989eeadfae95594bd7b904f5dd6a8d Mon Sep 17 00:00:00 2001 From: Scott Kay Date: Mon, 28 Oct 2024 13:51:32 -0400 Subject: [PATCH 2/2] review feedback --- metrics/config/metrics_test.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/metrics/config/metrics_test.go b/metrics/config/metrics_test.go index 789b573cb85..df663ba0f38 100644 --- a/metrics/config/metrics_test.go +++ b/metrics/config/metrics_test.go @@ -39,17 +39,14 @@ func TestGoMetricsEngine(t *testing.T) { } } -// Test the multiengine func TestMultiMetricsEngine(t *testing.T) { cfg := mainConfig.Configuration{} cfg.Metrics.Influxdb.Host = "localhost" adapterList := openrtb_ext.CoreBidderNames() goEngine := metrics.NewMetrics(gometrics.NewPrefixedRegistry("prebidserver."), adapterList, mainConfig.DisabledMetrics{}, nil, modulesStages) - engineList := make(MultiMetricsEngine, 2) - engineList[0] = goEngine - engineList[1] = &NilMetricsEngine{} - var metricsEngine metrics.MetricsEngine - metricsEngine = &engineList + metricsEngine := make(MultiMetricsEngine, 2) + metricsEngine[0] = goEngine + metricsEngine[1] = &NilMetricsEngine{} labels := metrics.Labels{ Source: metrics.DemandWeb, RType: metrics.ReqTypeORTB2Web, @@ -150,14 +147,14 @@ func TestMultiMetricsEngine(t *testing.T) { //Make the metrics engine, instantiated here with goEngine, fill its RequestStatuses[RequestType][metrics.RequestStatusXX] with the new boolean values added to metrics.Labels VerifyMetrics(t, "RequestStatuses.OpenRTB2.OK", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusOK].Count(), 5) VerifyMetrics(t, "RequestStatuses.AMP.OK", goEngine.RequestStatuses[metrics.ReqTypeAMP][metrics.RequestStatusOK].Count(), 0) - VerifyMetrics(t, "RequestStatuses.AMP.BlockedAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeAMP][metrics.RequestStatusBlockedApp].Count(), 1) + VerifyMetrics(t, "RequestStatuses.AMP.BlockedApp", goEngine.RequestStatuses[metrics.ReqTypeAMP][metrics.RequestStatusBlockedApp].Count(), 1) VerifyMetrics(t, "RequestStatuses.Video.OK", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusOK].Count(), 0) VerifyMetrics(t, "RequestStatuses.Video.Error", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusErr].Count(), 0) VerifyMetrics(t, "RequestStatuses.Video.BadInput", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusBadInput].Count(), 0) - VerifyMetrics(t, "RequestStatuses.Video.BlockededAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusBlockedApp].Count(), 1) + VerifyMetrics(t, "RequestStatuses.Video.BlockedApp", goEngine.RequestStatuses[metrics.ReqTypeVideo][metrics.RequestStatusBlockedApp].Count(), 1) VerifyMetrics(t, "RequestStatuses.OpenRTB2.Error", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusErr].Count(), 0) VerifyMetrics(t, "RequestStatuses.OpenRTB2.BadInput", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusBadInput].Count(), 0) - VerifyMetrics(t, "RequestStatuses.OpenRTB2.BlockedAcctOrApp", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusBlockedApp].Count(), 0) + VerifyMetrics(t, "RequestStatuses.OpenRTB2.BlockedApp", goEngine.RequestStatuses[metrics.ReqTypeORTB2Web][metrics.RequestStatusBlockedApp].Count(), 0) VerifyMetrics(t, "ImpsTypeBanner", goEngine.ImpsTypeBanner.Count(), 5) VerifyMetrics(t, "ImpsTypeVideo", goEngine.ImpsTypeVideo.Count(), 3)