Skip to content

Conversation

@Net-burst
Copy link
Collaborator

@Net-burst Net-burst commented Feb 14, 2025

🔧 Type of changes

  • new bid adapter
  • bid adapter update
  • new feature
  • new analytics adapter
  • new module
  • module update
  • bugfix
  • documentation
  • configuration
  • dependency update
  • tech debt (test coverage, refactorings, etc.)

✨ What's the context?

Prebid Cache lacks the information about which account is storing the creative and can't emit any account metrics.

🧠 Rationale behind the change

This is a part of the effort to increase PBC traceability.

🔎 New Bid Adapter Checklist

  • verify email contact works
  • NO fully dynamic hostnames
  • geographic host parameters are NOT required
  • direct use of HTTP is prohibited - implement an existing Bidder interface that will do all the job
  • if the ORTB is just forwarded to the endpoint, use the generic adapter - define the new adapter as the alias of the generic adapter
  • cover an adapter configuration with an integration test

🧪 Test plan

How do you know the changes are safe to ship to production?

🏎 Quality check

  • Are your changes following our code style guidelines?
  • Are there any breaking changes in your code?
  • Does your test coverage exceed 90%?
  • Are there any erroneous console logs, debuggers or leftover code in your changes?

@Net-burst Net-burst requested review from And1sS and CTMBNara February 14, 2025 02:16
@Net-burst Net-burst changed the title Propagate account id in Prebid Cache payload Core: Improve traceability for Prebid Cache Feb 14, 2025
@Net-burst Net-burst force-pushed the prebid-cache-traceability branch 2 times, most recently from 402df05 to 055bca0 Compare February 14, 2025 19:29
@Net-burst Net-burst added the work in progress Signals not finished work label Feb 14, 2025
@Net-burst Net-burst force-pushed the prebid-cache-traceability branch from 055bca0 to 363a50f Compare February 14, 2025 19:41
@Net-burst Net-burst changed the title Core: Improve traceability for Prebid Cache Core: Improve traceability for Prebid Cache stores Feb 16, 2025
: accountIdLength + separatorCount;

final String cacheKey = hbCacheId != null ? hbCacheId : idGenerator.generateId();
if (cacheKey != null && traceInfoLength < cacheKey.length()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets invert if and return hbCacheId here. So that big chunk of the code will be without unnecessary indentation.

return resolveCacheKey(accountId, null);
}

// hbCacheId is accepted here to have a backwards-compatibility with video category mapping
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't comment code, please, remove.

Comment on lines 423 to 428
final String customCacheKey = resolveCustomCacheKey(resolvedCacheKey, bidInfo.getCategory());

final BidPutObject payload = BidPutObject.builder()
.aid(requestId)
.type("xml")
.key(customCacheKey != null ? customCacheKey : resolvedCacheKey)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move key decision making logic to resolveCacheKey function, so that it will truly resolve cache key.

Comment on lines 1003 to 1005
.bidid(null)
.bidder(null)
.timestamp(null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to populate null fields, even for clarification purposes. We don't do that + its also clear that if you don't include field in the builder, field will be null.

Comment on lines 972 to 985
final BidPutObject secondBidPutObject = BidPutObject.builder()
.type("xml")
.bidid("bidId2")
.bidder("bidder2")
.timestamp(1L)
.value(new TextNode("VAST"))
.build();
final BidPutObject thirdBidPutObject = BidPutObject.builder()
.type("text")
.bidid("bidId3")
.bidder("bidder3")
.timestamp(1L)
.value(new TextNode("VAST"))
.build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to test three objects, one will be sufficient. Here you test cache id functionality and not accompanying logic. Please, leave single put object to simplify test. And, as always, please, check for similar occurences.

Comment on lines 541 to 543
final Integer creativeTtl = cachedCreative.getPayload().getTtlseconds() != null
? cachedCreative.getPayload().getTtlseconds()
: cachedCreative.getPayload().getExpiry();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tend to avoid duplicating long method call chains. This can be simplified to smth like:

final Payload payload = cachedCreative.getPayload();
final Integer creativeTtl = ObjectUtil.defaultIfNull(payload.getTtlSeconds(), payload.getExpiry());

: cachedCreative.getPayload().getExpiry();

if (creativeTtl != null) {
metrics.updateCacheCreativeTtl(accountId,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move accountId to next line. Or, maybe, this can be one liner?

@osulzhenko osulzhenko requested a review from And1sS February 18, 2025 11:53
@Net-burst Net-burst removed the work in progress Signals not finished work label Feb 18, 2025
And1sS
And1sS previously approved these changes Feb 19, 2025
CTMBNara
CTMBNara previously approved these changes Feb 19, 2025
: accountId + TRACE_INFO_SEPARATOR + substring;
}

private String normalizeDatacenterRegion(String datacenterRegion) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static modifier

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gimme sec

@Net-burst Net-burst dismissed stale reviews from CTMBNara and And1sS via 69bf63d February 19, 2025 15:56
* Add functional tests for prebid cache trace ability

* update test

* Update after review

* Update after review

* Update after review
@CTMBNara CTMBNara merged commit c027e3c into master Feb 20, 2025
8 checks passed
@CTMBNara CTMBNara deleted the prebid-cache-traceability branch February 20, 2025 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants