Skip to content

Commit

Permalink
Add UKM/UMA for additional bids and negative interest groups.
Browse files Browse the repository at this point in the history
This adds several new metrics:
- ConfigPromisesResolved Latency shows the time between the start of the
  auction and the time at which the config promises are resolved.
- ConfigPromisesResolved CriticalPath shows the time between the start
  of the BiddingAndScoring phase (after interest groups have been
  loaded) and the time at which the config promises are resolved,
  effectively the time at which additional bids would have been delayed
  waiting for the config promises.
- AdditionalBidDecodeLatency metric show the latency for time spent
  decoding additional bids where that decoding was successful.
- NumAdditionalBids* show the frequency of various both error and
  non-error outcomes of additional bids.
- NumNegativeInterestGroups counts the negative interest groups
  associated with an auction. (For a multi-seller auction, this is the
  cumulative count of negative interest groups across all component
  auctions.)
- NumNegativeInterestGroupsIgnoredDueTo InvalidSignature or
  JoiningOriginMismatch counts the number of negative interest groups
  negatively targeted on an additional bid that were ignored because of
  some validation failure, as detaield in the "failed open" scenarios
  described in the explainer.
- NumAuctionsWithConfigPromises is the number of auctions in this
  auction (so, at most 1 in a single-seller auction, at most the number
  of component auctions plus one for the top-level auction in a
  multi-seller auction) that had config promises that were resolved.

UMA metrics appear for most of these metrics as well.
- Ads.InterestGroup.Auction.ConfigPromisesLatency
- Ads.InterestGroup.Auction.ConfigPromisesCriticalPathLatency
- Ads.InterestGroup.Auction.AdditionalBid.DecodeLatency
- Ads.InterestGroup.Auction.AdditionalBid.Result
- Ads.InterestGroup.Auction.NumNegativeInterestGroups

We don't include UMA for the NumNegativeInterestGroupsIgnoredDueTo UKM
because these would make the most sense relative to the number of
negative targeting interest groups considered, so that we'd ideally
record the frequency of all negative targeting results - not present,
present, ignored due to invalid signature, or ignored due to invalid
joining origin - but doing so would be slightly misleading, since
ShouldDropDueToNegativeTargeting skips all other negative interest
groups once one is found, which would bias that metric towards
present.

Change-Id: Ifa0e61e18d39cf1ba2dcd689b1d0ebba9b049b26
Bug: 1464874
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4943170
Reviewed-by: Maks Orlovich <morlovich@chromium.org>
Commit-Queue: Orr Bernstein <orrb@google.com>
Cr-Commit-Position: refs/heads/main@{#1216120}
  • Loading branch information
orrb1 authored and Chromium LUCI CQ committed Oct 27, 2023
1 parent 539e22e commit c81ad80
Show file tree
Hide file tree
Showing 15 changed files with 1,327 additions and 244 deletions.
1 change: 1 addition & 0 deletions content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ source_set("browser") {
"interest_group/ad_auction_service_impl.h",
"interest_group/ad_auction_url_loader_interceptor.cc",
"interest_group/ad_auction_url_loader_interceptor.h",
"interest_group/additional_bid_result.h",
"interest_group/additional_bids_util.cc",
"interest_group/additional_bids_util.h",
"interest_group/auction_metrics_recorder.cc",
Expand Down
58 changes: 58 additions & 0 deletions content/browser/interest_group/additional_bid_result.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_INTEREST_GROUP_ADDITIONAL_BID_RESULT_H_
#define CONTENT_BROWSER_INTEREST_GROUP_ADDITIONAL_BID_RESULT_H_

namespace content {

// Result of decoding an additional bid. Used for histograms. These values
// are persisted to logs. Entries should not be renumbered and numeric values
// should never be reused.
enum class AdditionalBidResult {
// The additional bid was sent for scoring to participate in the auction.
kSentForScoring = 0,

// The additional bid was suppressed because of the presence of at least one
// of its specified negative targeting interest groups.
kNegativeTargeted = 1,

// The additional bid was rejected because the signed additional bid in the
// Ad-Auction-Additional-Bid response header was not a valid base64 string.
kRejectedDueToInvalidBase64 = 2,

// The additional bid was rejected because the signed additional bid was
// invalid JSON, and so failed to parse.
kRejectedDueToSignedBidJsonParseError = 3,

// The additional bid was rejected because the signed additional bid JSON
// was not structured as expected.
kRejectedDueToSignedBidDecodeError = 4,

// The additional bid was rejected because the additional bid from inside
// the signed additional bid was invalid JSON.
kRejectedDueToJsonParseError = 5,

// The additional bid was rejected because the additional bid from inside
// the signed additional bid was not structured as expected. This is the
// result used when the replay-prevention fields - auctionNonce, seller and
// topLevelSeller - was missing or didn't match those of the auction. This
// is also the result used when the additional bid owner was not found in
// the auction's interestGroupBuyers.
kRejectedDueToDecodeError = 6,

// The additional bid was rejected because the additional bid's owner was
// not allowed to bid in that auction by IsInterestGroupAPIAllowed.
kRejectedDueToBuyerNotAllowed = 7,

// The additional bid was rejected because the additional bid specified a
// currency that didn't match the currency associated with that buyer.
kRejectedDueToCurrencyMismatch = 8,

kMaxValue = kRejectedDueToCurrencyMismatch
};

} // namespace content

#endif // CONTENT_BROWSER_INTEREST_GROUP_ADDITIONAL_BID_RESULT_H_
10 changes: 10 additions & 0 deletions content/browser/interest_group/additional_bids_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "base/types/optional_ref.h"
#include "base/uuid.h"
#include "base/values.h"
#include "content/browser/interest_group/auction_metrics_recorder.h"
#include "content/browser/interest_group/interest_group_auction.h"
#include "content/common/content_export.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
Expand Down Expand Up @@ -474,13 +475,18 @@ void AdAuctionNegativeTargeter::AddInterestGroupInfo(
spot.key = key;
}

size_t AdAuctionNegativeTargeter::GetNumNegativeInterestGroups() {
return negative_interest_groups_.size();
}

bool AdAuctionNegativeTargeter::ShouldDropDueToNegativeTargeting(
const url::Origin& buyer,
const absl::optional<url::Origin>& negative_target_joining_origin,
const std::vector<std::string>& negative_target_interest_group_names,
const std::vector<SignedAdditionalBidSignature>& signatures,
const std::vector<size_t>& valid_signatures,
const url::Origin& seller,
AuctionMetricsRecorder& auction_metrics_recorder,
std::vector<std::string>& errors_out) {
if (valid_signatures.size() != signatures.size()) {
errors_out.push_back(
Expand All @@ -504,6 +510,8 @@ bool AdAuctionNegativeTargeter::ShouldDropDueToNegativeTargeting(
// a matching signature.
if (!AdditionalBidKeyHasMatchingValidSignature(signatures, valid_signatures,
negative_info.key)) {
auction_metrics_recorder
.RecordNegativeInterestGroupIgnoredDueToInvalidSignature();
errors_out.push_back(base::StrCat(
{"Warning: Ignoring negative targeting group '", ig_name,
"' on an additional bid from '", buyer.Serialize(),
Expand All @@ -515,6 +523,8 @@ bool AdAuctionNegativeTargeter::ShouldDropDueToNegativeTargeting(
// Must also have proper joining origin, if applicable.
if (negative_target_joining_origin.has_value()) {
if (*negative_target_joining_origin != negative_info.joining_origin) {
auction_metrics_recorder
.RecordNegativeInterestGroupIgnoredDueToJoiningOriginMismatch();
errors_out.push_back(base::StrCat(
{"Warning: Ignoring negative targeting group '", ig_name,
"' on an additional bid from '", buyer.Serialize(),
Expand Down
6 changes: 6 additions & 0 deletions content/browser/interest_group/additional_bids_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "base/types/optional_ref.h"
#include "base/uuid.h"
#include "base/values.h"
#include "content/browser/interest_group/auction_metrics_recorder.h"
#include "content/browser/interest_group/interest_group_auction.h"
#include "content/common/content_export.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
Expand Down Expand Up @@ -109,6 +110,10 @@ class CONTENT_EXPORT AdAuctionNegativeTargeter {
const url::Origin& joining_origin,
const blink::InterestGroup::AdditionalBidKey& key);

// Returns the number of negative interest groups added to this targeter
// using AddInterestGroupInfo.
size_t GetNumNegativeInterestGroups();

// Returns true if negative targeting applies to a bid.
//
// `buyer` is the purported origin of the additional bid.
Expand All @@ -135,6 +140,7 @@ class CONTENT_EXPORT AdAuctionNegativeTargeter {
const std::vector<SignedAdditionalBidSignature>& signatures,
const std::vector<size_t>& valid_signatures,
const url::Origin& seller,
AuctionMetricsRecorder& auction_metrics_recorder,
std::vector<std::string>& errors_out);

private:
Expand Down

0 comments on commit c81ad80

Please sign in to comment.