Add additional Prebid debug flags to OpenRTB requests#377
Add additional Prebid debug flags to OpenRTB requests#377ChristianPavilonis wants to merge 6 commits intomainfrom
Conversation
|
Do we want this in the /auction response, or are debug logs good? |
|
Let's return response if prebid integration is enabled with debug = |
f204475 to
3d752dc
Compare
…se_metadata with tests
PubMatic (and likely other bidders) heavily throttle fill on test:1 traffic (~10% vs ~100%). Previously debug=true set test:1, debug ext fields, and returnallbidstatus together. Now test:1 is controlled by a separate test_mode config param so debug diagnostics can be enabled in production without killing fill rates.
Without this, PBS infers the IP from the incoming connection which is a Fastly edge/data-center IP. Bidders like PubMatic filter data-center IPs as non-human traffic, resulting in 0% fill through Trusted Server. The client IP is already available via get_client_ip_addr() and stored in DeviceInfo.ip — it just wasn't being passed through to the OpenRTB Device object.
Investigation: PubMatic no-bid root causesDebugged why PubMatic was returning 204 (no-bid) on every request through Trusted Server. Found two independent issues: Issue 1:
|
| Condition | PubMatic Fill Rate |
|---|---|
Without test: 1 |
10/10 (100%) |
With test: 1 |
1/10 (10%) |
Fix: Decoupled test: 1 into a separate test_mode config param (commit 19c7feb). debug: true still enables ext.prebid.debug and returnallbidstatus for diagnostics.
Issue 2: Fastly edge IP forwarded instead of real client IP
After removing test: 1, PubMatic was still returning 204 through the staging Fastly server (0/10). The OpenRTB Device struct didn't include an ip field, so PBS inferred the IP from the incoming connection — a Fastly data-center IP (157.52.114.28). PubMatic filters data-center IPs as non-human traffic.
The real client IP was already captured in DeviceInfo.ip via get_client_ip_addr() — it just wasn't being passed through to the OpenRTB request.
Fix: Added ip field to the OpenRTB Device struct (commit cb0486f).
Verified on staging
After deploying both fixes to the staging Fastly instance (167.82.82.98):
run 1: {"pm_status":200,"pm_ip":"104.12.33.82","bidders":["mocktioneer","pubmatic"]}
run 2: {"pm_status":204,"pm_ip":"104.12.33.82","bidders":["kargo","mocktioneer"]}
run 3: {"pm_status":200,"pm_ip":"104.12.33.82","bidders":["mocktioneer","pubmatic"]}
run 4: {"pm_status":204,"pm_ip":"104.12.33.82","bidders":["mocktioneer"]}
run 5: {"pm_status":200,"pm_ip":"104.12.33.82","bidders":["mocktioneer","pubmatic"]}
run 6: {"pm_status":200,"pm_ip":"104.12.33.82","bidders":["kargo","mocktioneer","pubmatic"]}
run 7: {"pm_status":200,"pm_ip":"104.12.33.82","bidders":["mocktioneer","pubmatic"]}
run 8: {"pm_status":200,"pm_ip":"104.12.33.82","bidders":["mocktioneer","pubmatic"]}
run 9: {"pm_status":200,"pm_ip":"104.12.33.82","bidders":["mocktioneer","pubmatic"]}
run 10: {"pm_status":200,"pm_ip":"104.12.33.82","bidders":["kargo","mocktioneer","pubmatic"]}
PubMatic fill: 8/10 (80%), up from 0%. Real client IP (104.12.33.82) correctly forwarded in device.ip. Kargo also started bidding.
Additional finding: PubMatic only bids on 300x250
Tested all size combinations against PBS directly. PubMatic adSlot 4407979 (publisher 156229) only has demand for 300x250:
| Sizes | Fill |
|---|---|
| 970x90, 728x90, 970x250 (header only) | 0/5 (0%) |
| 300x250 only | 4/5 (80%) |
| 300x250 + 728x90 + 970x90 + 970x250 (in_content) | 3/5 (60%) |
The header ad slot will never get PubMatic bids since it doesn't include 300x250. This is a PubMatic-side slot configuration issue, not a Trusted Server bug.
Summary
Adds debug diagnostics to Prebid/OpenRTB bid requests, surfaces Prebid Server debug response data in the
/auctionendpoint response, and forwards the real client IP to PBS so bidders see residential rather than data-center traffic.Changes
New
test_modeconfig param (prebid.rs, config)Added a separate
test_modeconfig flag that controls the OpenRTBtest: 1field independently fromdebug. This is intentionally separate becausetest: 1signals non-billable traffic and bidders like PubMatic heavily throttle fill (~10% vs ~100%). Defaults tofalse.debug: true— enablesext.prebid.debug,ext.prebid.returnallbidstatus, debug response metadata, and debug loggingtest_mode: true— setstest: 1in the OpenRTB request (defaults tofalse)Forward real client IP in
device.ip(openrtb.rs,prebid.rs)Added
ipfield to the OpenRTBDevicestruct, populated fromDeviceInfo.ip(the real client IP fromget_client_ip_addr()). Without this, PBS infers the IP from the incoming connection — a Fastly edge/data-center IP — causing bidders to filter the traffic as non-human (0% fill through Trusted Server).OpenRTB request debug flags (
openrtb.rs,prebid.rs)When
config.debugis enabled, the outgoing OpenRTB request now includes:{ "ext": { "prebid": { "debug": true, "returnallbidstatus": true } } }ext.prebid.debug: true— enables Prebid Server debug output (httpcalls, resolvedrequest)ext.prebid.returnallbidstatus: true— includes all bid statuses (rejected/no-bid reasons) in the responseAll fields are omitted from serialization when debug is disabled (default).
Response debug logging (
prebid.rs)Added
log::debug!of the full Prebid Server response JSON inparse_response(), gated on bothconfig.debugandlog::log_enabled!(Level::Debug)to avoid wasted serialization.Debug data in
/auctionresponse (prebid.rs)Extracted
enrich_response_metadata()method that attaches Prebid Server response metadata toAuctionResponse.metadata, which flows throughProviderSummary→provider_detailsin the/auctionresponseext:Always-on fields (present whenever PBS returns them):
responsetimemillis— per-bidder response timeserrors— per-bidder errorswarnings— per-bidder warnings (new)Debug-gated fields (only when
config.debugis true):debug— fullext.debugblob (httpcalls, resolvedrequest)bidstatus— per-bid status array fromext.prebid.bidstatusSafety
log::warn!emitted whendebug: trueis configured, alerting operators that debug data will be included in/auctionresponsesNone/omitted — no behavior change when debug is disabledTests
to_openrtb_includes_debug_flags_when_enabled— verifies debug flags set without test:1to_openrtb_sets_test_flag_when_test_mode_enabled— verifies test:1 only with test_modeto_openrtb_omits_debug_flags_when_disabled— verifies fields areNoneand omitted from JSONenrich_response_metadata_attaches_always_on_fields— verifies always-on metadata present, debug-gated fields absentenrich_response_metadata_includes_debug_fields_when_enabled— verifies debug + bidstatus present with correct values