Skip to content

Commit

Permalink
Add ability to prevent propagating experiment ids from WWW
Browse files Browse the repository at this point in the history
Summary:
This diff adds the ability to prevent propagating experiment IDs from async jobs in WWW to Thrift services, and also adds gates to the methods that  set & add experiment ids.

I had already created the `lumos/experimentation:disable_www_exp_id_propagation` knob before I moved that logic from makeV to the specific call site in `FalcoFabricAsyncWriter`.

These calls are temporary to understand whether anything is calling add/set at all. If there is logic that is somehow adding/setting experiment ids, the JK UI will display the # of hits and we'll log a warning with the ids (and get a stacktrace). If it never gets hit (ie. nothing is calling add/set experiment ids), the JK UI will show no hits, and we will know for certain that the ids are being ingested via headers.

I also added a JK to control the rate at which we will log these api violations: `lumos/experimentation:www_experiment_id_api_violation_sampling_rate`. This is a safeguard in case we're somehow calling set/add experiment ids a lot, in which case we can log less by tweaking this rate.

Differential Revision: D70640520

fbshipit-source-id: daf2b61fbad166b392482e37cf09f725b93d8918
  • Loading branch information
Arman Ozturk authored and facebook-github-bot committed Mar 5, 2025
1 parent cc96834 commit d337ec9
Showing 1 changed file with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ public static function getOriginIdResolver()[]: (function()[leak_safe]: int) {
MCPProductID::UNKNOWN;
}

public function clearExperimentIds()[write_props]: void {
$this->storage->experiment_ids = null;
}

public function getExperimentIds()[]: vec<int> {
$ret = $this->storage->experiment_ids;
if ($ret !== null) {
Expand All @@ -454,18 +458,42 @@ public function getExperimentIds()[]: vec<int> {
return vec[];
}

public function addExperimentId(int $eid)[write_props]: void {
public function addExperimentId(int $eid)[zoned_shallow]: void {
if (!static::isExperimentIdModificationAllowed()) {
return;
}
$v = $this->getExperimentIds();
$v[] = $eid;
$this->storage->experiment_ids = $v;
$this->dirty();
}

public function setExperimentIds(vec<int> $eids)[write_props]: void {
public function setExperimentIds(vec<int> $eids)[zoned_shallow]: void {
if (!static::isExperimentIdModificationAllowed()) {
return;
}
$this->storage->experiment_ids = $eids;
$this->dirty();
}

private static function isExperimentIdModificationAllowed(
)[zoned_shallow]: bool {
if (
!JustKnobs::eval('lumos/experimentation:enable_www_experiment_id_api')
) {
$sampling_rate = JustKnobs::getInt(
'lumos/experimentation:www_experiment_id_api_violation_sampling_rate',
);
if (coinflip($sampling_rate)) {
FBLogger('lumos_experimentation', 'disallowed experiment id call')
->setBlameOwner('lumos')
->warn('Experiment ID modifications are disallowed!');
}
return false;
}
return true;
}

/**
* This should not be exposed publicly, and instead call
* getPrivacyUniverseDesignator
Expand Down

0 comments on commit d337ec9

Please sign in to comment.