-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug disable feature implementation: #1677
Changes from 10 commits
a5886cd
2e05c58
4c7d53a
c7ca474
f485731
9821fd3
5f1e090
fdbe72f
6c64aa8
d40309a
e482baf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ type Account struct { | |
EventsEnabled bool `mapstructure:"events_enabled" json:"events_enabled"` | ||
CCPA AccountCCPA `mapstructure:"ccpa" json:"ccpa"` | ||
GDPR AccountGDPR `mapstructure:"gdpr" json:"gdpr"` | ||
DebugAllowed bool `mapstructure:"debug_allowed" json:"debug_allowed"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my comment above in the bidder config, should debug be allowed by default? Perhaps a pointer or rename if the default should be to allow? Edit: on second thought, this is ok since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be DebugAllow / debug_allow per the spec and to coordinate with debug.allow in the bidder info. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
|
||
// AccountCCPA represents account-specific CCPA configuration | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ func buildExchangeBidders(cfg *config.Configuration, infos adapters.BidderInfos, | |
|
||
exchangeBidders := make(map[openrtb_ext.BidderName]adaptedBidder, len(bidders)) | ||
for bidderName, bidder := range bidders { | ||
exchangeBidders[bidderName] = adaptBidder(bidder, client, cfg, me, bidderName) | ||
exchangeBidders[bidderName] = adaptBidder(bidder, client, cfg, me, bidderName, infos[bidderName.String()].Debug) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a guarantee that
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
} | ||
|
||
return exchangeBidders, nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ type adaptedBidder interface { | |
// | ||
// Any errors will be user-facing in the API. | ||
// Error messages should help publishers understand what might account for "bad" bids. | ||
requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo) (*pbsOrtbSeatBid, []error) | ||
requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) | ||
} | ||
|
||
// pbsOrtbBid is a Bid returned by an adaptedBidder. | ||
|
@@ -93,7 +93,7 @@ type pbsOrtbSeatBid struct { | |
// | ||
// The name refers to the "Adapter" architecture pattern, and should not be confused with a Prebid "Adapter" | ||
// (which is being phased out and replaced by Bidder for OpenRTB auctions) | ||
func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Configuration, me metrics.MetricsEngine, name openrtb_ext.BidderName) adaptedBidder { | ||
func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Configuration, me metrics.MetricsEngine, name openrtb_ext.BidderName, debugInfo *adapters.DebugInfo) adaptedBidder { | ||
return &bidderAdapter{ | ||
Bidder: bidder, | ||
BidderName: name, | ||
|
@@ -102,10 +102,18 @@ func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Config | |
config: bidderAdapterConfig{ | ||
Debug: cfg.Debug, | ||
DisableConnMetrics: cfg.Metrics.Disabled.AdapterConnectionMetrics, | ||
DebugInfo: adapters.DebugInfo{Allow: parseDebugInfo(debugInfo)}, | ||
}, | ||
} | ||
} | ||
|
||
func parseDebugInfo(info *adapters.DebugInfo) bool { | ||
if info == nil { | ||
return true | ||
} | ||
return info.Allow | ||
} | ||
|
||
type bidderAdapter struct { | ||
Bidder adapters.Bidder | ||
BidderName openrtb_ext.BidderName | ||
|
@@ -117,9 +125,10 @@ type bidderAdapter struct { | |
type bidderAdapterConfig struct { | ||
Debug config.Debug | ||
DisableConnMetrics bool | ||
DebugInfo adapters.DebugInfo | ||
} | ||
|
||
func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo) (*pbsOrtbSeatBid, []error) { | ||
func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { | ||
reqData, errs := bidder.Bidder.MakeRequests(request, reqInfo) | ||
|
||
if len(reqData) == 0 { | ||
|
@@ -155,8 +164,16 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.Bi | |
for i := 0; i < len(reqData); i++ { | ||
httpInfo := <-responseChannel | ||
// If this is a test bid, capture debugging info from the requests. | ||
// Write debug data to ext in case if: | ||
// - debugContextKey (url param) in true | ||
// - account debug is allowed | ||
// - bidder debug is allowed | ||
if debugInfo := ctx.Value(DebugContextKey); debugInfo != nil && debugInfo.(bool) { | ||
seatBid.httpCalls = append(seatBid.httpCalls, makeExt(httpInfo)) | ||
if accountDebugAllowed { | ||
if bidder.config.DebugInfo.Allow { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like we need debug enabled at both the bidder and the account level to see debug information. If that's the case, do we need the bidder level setting? Maybe we're requiring it as well as a safeguard... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case we bid more than one bidder in one request, some of those bidders may have debug.allowed=true and others may have debug.allowed=false. For this case we need to make 2 checks(account and bidder level) and write logs for those bidders where debug.allowed=true. Hope this make sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait... did my comment disappear? We may bid more than one bidder in one request and those bidders may have different debug options. To handle this case we need to check each of them and log data only for those bidders where debug.allow = true. Hope this makes sense and answers your question. |
||
seatBid.httpCalls = append(seatBid.httpCalls, makeExt(httpInfo)) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you combine the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, was going to to this too, done! :) |
||
} | ||
|
||
if httpInfo.err == nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should debug be allowed by default? If so, perhaps this should be a pointer so we can detect when it's missing or renamed (e.g. Disallow) so that the default value of false is appropriate when the field is missing?
Edit: I see @hhhjort mentioned this in another comment. Technically this is ok right now because
Allow
is the only field inDebugInfo
so we could go with the implementation here where we rely on checking for the presence ofDebug
. However, it's possible we add additional fields toDebugInfo
in the future, in which case we probably don't want to solely rely on checking for the presence ofDebug
to determine if we need to setAllow
to the default. Maybe we don't care about that right now and will just refactor in the future if additional fields are added toDebugInfo
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The entire
DebugInfo
structure is a pointer currently. I think that's fine.As you said, another option is to make the
Debug
field inBidderInfo
not a pointer and add a pointer here. That would make it more future proof, but the current approach solves the problem at hand. tomato/tomato IMHO.