From ddf897c861bfb9cd026834161c43e53287120ff1 Mon Sep 17 00:00:00 2001 From: AlexBVolcy <74930484+AlexBVolcy@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:07:49 -0400 Subject: [PATCH] Update Cookie Sync Chooser Debug Message to match Java (#3558) --- endpoints/cookie_sync.go | 8 ++++---- endpoints/cookie_sync_test.go | 10 +++++----- metrics/go_metrics_test.go | 4 ++-- metrics/metrics.go | 4 ++-- metrics/prometheus/prometheus_test.go | 2 +- usersync/chooser.go | 6 +++--- usersync/chooser_test.go | 8 ++++---- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/endpoints/cookie_sync.go b/endpoints/cookie_sync.go index d6e0b31a096..42b67aa551b 100644 --- a/endpoints/cookie_sync.go +++ b/endpoints/cookie_sync.go @@ -402,8 +402,8 @@ func (c *cookieSyncEndpoint) writeSyncerMetrics(biddersEvaluated []usersync.Bidd c.metrics.RecordSyncerRequest(bidder.SyncerKey, metrics.SyncerCookieSyncPrivacyBlocked) case usersync.StatusAlreadySynced: c.metrics.RecordSyncerRequest(bidder.SyncerKey, metrics.SyncerCookieSyncAlreadySynced) - case usersync.StatusTypeNotSupported: - c.metrics.RecordSyncerRequest(bidder.SyncerKey, metrics.SyncerCookieSyncTypeNotSupported) + case usersync.StatusRejectedByFilter: + c.metrics.RecordSyncerRequest(bidder.SyncerKey, metrics.SyncerCookieSyncRejectedByFilter) } } } @@ -524,8 +524,8 @@ func getDebugMessage(status usersync.Status) string { return "Unsupported bidder" case usersync.StatusUnconfiguredBidder: return "No sync config" - case usersync.StatusTypeNotSupported: - return "Type not supported" + case usersync.StatusRejectedByFilter: + return "Rejected by request filter" case usersync.StatusBlockedByDisabledUsersync: return "Sync disabled by config" } diff --git a/endpoints/cookie_sync_test.go b/endpoints/cookie_sync_test.go index d00c8211993..0ae30e60be8 100644 --- a/endpoints/cookie_sync_test.go +++ b/endpoints/cookie_sync_test.go @@ -1642,10 +1642,10 @@ func TestCookieSyncWriteBidderMetrics(t *testing.T) { }, }, { - description: "One - Type Not Supported", - given: []usersync.BidderEvaluation{{Bidder: "a", SyncerKey: "aSyncer", Status: usersync.StatusTypeNotSupported}}, + description: "One - Rejected By Filter", + given: []usersync.BidderEvaluation{{Bidder: "a", SyncerKey: "aSyncer", Status: usersync.StatusRejectedByFilter}}, setExpectations: func(m *metrics.MetricsEngineMock) { - m.On("RecordSyncerRequest", "aSyncer", metrics.SyncerCookieSyncTypeNotSupported).Once() + m.On("RecordSyncerRequest", "aSyncer", metrics.SyncerCookieSyncRejectedByFilter).Once() }, }, { @@ -1699,7 +1699,7 @@ func TestCookieSyncHandleResponse(t *testing.T) { {Bidder: "Bidder2", Status: usersync.StatusUnknownBidder}, {Bidder: "Bidder3", Status: usersync.StatusUnconfiguredBidder}, {Bidder: "Bidder4", Status: usersync.StatusBlockedByPrivacy}, - {Bidder: "Bidder5", Status: usersync.StatusTypeNotSupported}, + {Bidder: "Bidder5", Status: usersync.StatusRejectedByFilter}, {Bidder: "Bidder6", Status: usersync.StatusBlockedByUserOptOut}, {Bidder: "Bidder7", Status: usersync.StatusBlockedByDisabledUsersync}, {Bidder: "BidderA", Status: usersync.StatusDuplicate, SyncerKey: "syncerB"}, @@ -1792,7 +1792,7 @@ func TestCookieSyncHandleResponse(t *testing.T) { givenCookieHasSyncs: true, givenDebug: true, givenSyncersChosen: []usersync.SyncerChoice{}, - expectedJSON: `{"status":"ok","bidder_status":[],"debug":[{"bidder":"Bidder1","error":"Already in sync"},{"bidder":"Bidder2","error":"Unsupported bidder"},{"bidder":"Bidder3","error":"No sync config"},{"bidder":"Bidder4","error":"Rejected by privacy"},{"bidder":"Bidder5","error":"Type not supported"},{"bidder":"Bidder6","error":"Status blocked by user opt out"},{"bidder":"Bidder7","error":"Sync disabled by config"},{"bidder":"BidderA","error":"Duplicate bidder synced as syncerB"}]}` + "\n", + expectedJSON: `{"status":"ok","bidder_status":[],"debug":[{"bidder":"Bidder1","error":"Already in sync"},{"bidder":"Bidder2","error":"Unsupported bidder"},{"bidder":"Bidder3","error":"No sync config"},{"bidder":"Bidder4","error":"Rejected by privacy"},{"bidder":"Bidder5","error":"Rejected by request filter"},{"bidder":"Bidder6","error":"Status blocked by user opt out"},{"bidder":"Bidder7","error":"Sync disabled by config"},{"bidder":"BidderA","error":"Duplicate bidder synced as syncerB"}]}` + "\n", expectedAnalytics: analytics.CookieSyncObject{Status: 200, BidderStatus: []*analytics.CookieSyncBidder{}}, }, } diff --git a/metrics/go_metrics_test.go b/metrics/go_metrics_test.go index 7cacd9099db..a9f393a89b0 100644 --- a/metrics/go_metrics_test.go +++ b/metrics/go_metrics_test.go @@ -73,7 +73,7 @@ func TestNewMetrics(t *testing.T) { ensureContains(t, registry, "syncer.foo.request.ok", m.SyncerRequestsMeter["foo"][SyncerCookieSyncOK]) ensureContains(t, registry, "syncer.foo.request.privacy_blocked", m.SyncerRequestsMeter["foo"][SyncerCookieSyncPrivacyBlocked]) ensureContains(t, registry, "syncer.foo.request.already_synced", m.SyncerRequestsMeter["foo"][SyncerCookieSyncAlreadySynced]) - ensureContains(t, registry, "syncer.foo.request.type_not_supported", m.SyncerRequestsMeter["foo"][SyncerCookieSyncTypeNotSupported]) + ensureContains(t, registry, "syncer.foo.request.rejected_by_filter", m.SyncerRequestsMeter["foo"][SyncerCookieSyncRejectedByFilter]) ensureContains(t, registry, "syncer.foo.set.ok", m.SyncerSetsMeter["foo"][SyncerSetUidOK]) ensureContains(t, registry, "syncer.foo.set.cleared", m.SyncerSetsMeter["foo"][SyncerSetUidCleared]) @@ -908,7 +908,7 @@ func TestRecordSyncerRequest(t *testing.T) { assert.Equal(t, m.SyncerRequestsMeter["foo"][SyncerCookieSyncOK].Count(), int64(1)) assert.Equal(t, m.SyncerRequestsMeter["foo"][SyncerCookieSyncPrivacyBlocked].Count(), int64(0)) assert.Equal(t, m.SyncerRequestsMeter["foo"][SyncerCookieSyncAlreadySynced].Count(), int64(0)) - assert.Equal(t, m.SyncerRequestsMeter["foo"][SyncerCookieSyncTypeNotSupported].Count(), int64(0)) + assert.Equal(t, m.SyncerRequestsMeter["foo"][SyncerCookieSyncRejectedByFilter].Count(), int64(0)) } func TestRecordSetUid(t *testing.T) { diff --git a/metrics/metrics.go b/metrics/metrics.go index 2696c642e21..f9cb937174b 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -361,7 +361,7 @@ const ( SyncerCookieSyncOK SyncerCookieSyncStatus = "ok" SyncerCookieSyncPrivacyBlocked SyncerCookieSyncStatus = "privacy_blocked" SyncerCookieSyncAlreadySynced SyncerCookieSyncStatus = "already_synced" - SyncerCookieSyncTypeNotSupported SyncerCookieSyncStatus = "type_not_supported" + SyncerCookieSyncRejectedByFilter SyncerCookieSyncStatus = "rejected_by_filter" ) // SyncerRequestStatuses returns possible syncer statuses. @@ -370,7 +370,7 @@ func SyncerRequestStatuses() []SyncerCookieSyncStatus { SyncerCookieSyncOK, SyncerCookieSyncPrivacyBlocked, SyncerCookieSyncAlreadySynced, - SyncerCookieSyncTypeNotSupported, + SyncerCookieSyncRejectedByFilter, } } diff --git a/metrics/prometheus/prometheus_test.go b/metrics/prometheus/prometheus_test.go index fcb9ba6452c..8a42bf46845 100644 --- a/metrics/prometheus/prometheus_test.go +++ b/metrics/prometheus/prometheus_test.go @@ -1235,7 +1235,7 @@ func TestRecordSyncerRequestMetric(t *testing.T) { label: "already_synced", }, { - status: metrics.SyncerCookieSyncTypeNotSupported, + status: metrics.SyncerCookieSyncRejectedByFilter, label: "type_not_supported", }, } diff --git a/usersync/chooser.go b/usersync/chooser.go index d8bf731f693..462ed635e5a 100644 --- a/usersync/chooser.go +++ b/usersync/chooser.go @@ -86,8 +86,8 @@ const ( // StatusUnknownBidder specifies a requested bidder is unknown to Prebid Server. StatusUnknownBidder - // StatusTypeNotSupported specifies a requested sync type is not supported by a specific bidder. - StatusTypeNotSupported + // StatusRejectedByFilter specifies a requested sync type is not supported by a specific bidder. + StatusRejectedByFilter // StatusDuplicate specifies the bidder is a duplicate or shared a syncer key with another bidder choice. StatusDuplicate @@ -181,7 +181,7 @@ func (c standardChooser) evaluate(bidder string, syncersSeen map[string]struct{} syncersSeen[syncer.Key()] = struct{}{} if !syncer.SupportsType(syncTypeFilter.ForBidder(strings.ToLower(bidder))) { - return nil, BidderEvaluation{Status: StatusTypeNotSupported, Bidder: bidder, SyncerKey: syncer.Key()} + return nil, BidderEvaluation{Status: StatusRejectedByFilter, Bidder: bidder, SyncerKey: syncer.Key()} } if cookie.HasLiveSync(syncer.Key()) { diff --git a/usersync/chooser_test.go b/usersync/chooser_test.go index f48dbeff9f1..9e57f1da4ce 100644 --- a/usersync/chooser_test.go +++ b/usersync/chooser_test.go @@ -153,7 +153,7 @@ func TestChooserChoose(t *testing.T) { bidderNamesLookup: normalizedBidderNamesLookup, expected: Result{ Status: StatusOK, - BiddersEvaluated: []BidderEvaluation{{Bidder: "c", SyncerKey: "keyC", Status: StatusTypeNotSupported}}, + BiddersEvaluated: []BidderEvaluation{{Bidder: "c", SyncerKey: "keyC", Status: StatusRejectedByFilter}}, SyncersChosen: []SyncerChoice{}, }, }, @@ -228,7 +228,7 @@ func TestChooserChoose(t *testing.T) { bidderNamesLookup: normalizedBidderNamesLookup, expected: Result{ Status: StatusOK, - BiddersEvaluated: []BidderEvaluation{{Bidder: "c", SyncerKey: "keyC", Status: StatusTypeNotSupported}, {Bidder: "a", SyncerKey: "keyA", Status: StatusOK}}, + BiddersEvaluated: []BidderEvaluation{{Bidder: "c", SyncerKey: "keyC", Status: StatusRejectedByFilter}, {Bidder: "a", SyncerKey: "keyA", Status: StatusOK}}, SyncersChosen: []SyncerChoice{syncerChoiceA}, }, }, @@ -243,7 +243,7 @@ func TestChooserChoose(t *testing.T) { bidderNamesLookup: normalizedBidderNamesLookup, expected: Result{ Status: StatusOK, - BiddersEvaluated: []BidderEvaluation{{Bidder: "a", SyncerKey: "keyA", Status: StatusOK}, {Bidder: "c", SyncerKey: "keyC", Status: StatusTypeNotSupported}}, + BiddersEvaluated: []BidderEvaluation{{Bidder: "a", SyncerKey: "keyA", Status: StatusOK}, {Bidder: "c", SyncerKey: "keyC", Status: StatusRejectedByFilter}}, SyncersChosen: []SyncerChoice{syncerChoiceA}, }, }, @@ -531,7 +531,7 @@ func TestChooserEvaluate(t *testing.T) { givenSyncTypeFilter: syncTypeFilter, normalizedBidderNamesLookup: normalizedBidderNamesLookup, expectedSyncer: nil, - expectedEvaluation: BidderEvaluation{Bidder: "b", SyncerKey: "keyB", Status: StatusTypeNotSupported}, + expectedEvaluation: BidderEvaluation{Bidder: "b", SyncerKey: "keyB", Status: StatusRejectedByFilter}, }, { description: "Already Synced",