Skip to content

Commit

Permalink
Update Cookie Sync Chooser Debug Message to match Java (#3558)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBVolcy authored Oct 29, 2024
1 parent a23380f commit ddf897c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions endpoints/cookie_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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"
}
Expand Down
10 changes: 5 additions & 5 deletions endpoints/cookie_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
},
{
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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{}},
},
}
Expand Down
4 changes: 2 additions & 2 deletions metrics/go_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -370,7 +370,7 @@ func SyncerRequestStatuses() []SyncerCookieSyncStatus {
SyncerCookieSyncOK,
SyncerCookieSyncPrivacyBlocked,
SyncerCookieSyncAlreadySynced,
SyncerCookieSyncTypeNotSupported,
SyncerCookieSyncRejectedByFilter,
}
}

Expand Down
2 changes: 1 addition & 1 deletion metrics/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ func TestRecordSyncerRequestMetric(t *testing.T) {
label: "already_synced",
},
{
status: metrics.SyncerCookieSyncTypeNotSupported,
status: metrics.SyncerCookieSyncRejectedByFilter,
label: "type_not_supported",
},
}
Expand Down
6 changes: 3 additions & 3 deletions usersync/chooser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()) {
Expand Down
8 changes: 4 additions & 4 deletions usersync/chooser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
},
},
Expand Down Expand Up @@ -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},
},
},
Expand All @@ -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},
},
},
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit ddf897c

Please sign in to comment.