Skip to content

Commit e2bf90c

Browse files
authored
Log when opt-in or opt-out of ALL experiments (#15144)
1 parent d955fda commit e2bf90c

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"Pylance.pylanceNotInstalledMessage": "Pylance extension is not installed.",
5454
"Pylance.pylanceInstalledReloadPromptMessage": "Pylance extension is now installed. Reload window to activate?",
5555
"Experiments.inGroup": "User belongs to experiment group '{0}'",
56+
"Experiments.optedOutOf": "User opted out of experiment group '{0}'",
5657
"Interpreters.RefreshingInterpreters": "Refreshing Python Interpreters",
5758
"Interpreters.entireWorkspace": "Entire workspace",
5859
"Interpreters.pythonInterpreterPath": "Python interpreter path: {0}",

src/client/common/experiments/service.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,48 @@ export class ExperimentService implements IExperimentService {
113113
}
114114

115115
private logExperiments() {
116+
if (this._optOutFrom.includes('All')) {
117+
// We prioritize opt out first
118+
this.output.appendLine(Experiments.optedOutOf().format('All'));
119+
120+
// Since we are in the Opt Out all case, this means when checking for experiment we
121+
// short circuit and return. So, printing out additional experiment info might cause
122+
// confusion. So skip printing out any specific experiment details to the log.
123+
return;
124+
} else if (this._optInto.includes('All')) {
125+
// Only if 'All' is not in optOut then check if it is in Opt In.
126+
this.output.appendLine(Experiments.inGroup().format('All'));
127+
128+
// Similar to the opt out case. If user is opting into to all experiments we short
129+
// circuit the experiment checks. So, skip printing any additional details to the logs.
130+
return;
131+
}
132+
116133
const experiments = this.globalState.get<{ features: string[] }>(EXP_MEMENTO_KEY, { features: [] });
117134

135+
// Log experiments that users manually opt out, these are experiments which are added using the exp framework.
136+
this._optOutFrom
137+
.filter((exp) => exp !== 'All' && exp.toLowerCase().startsWith('python'))
138+
.forEach((exp) => {
139+
this.output.appendLine(Experiments.optedOutOf().format(exp));
140+
});
141+
142+
// Log experiments that users manually opt into, these are experiments which are added using the exp framework.
143+
this._optInto
144+
.filter((exp) => exp !== 'All' && exp.toLowerCase().startsWith('python'))
145+
.forEach((exp) => {
146+
this.output.appendLine(Experiments.inGroup().format(exp));
147+
});
148+
149+
// Log experiments that users are added to by the exp framework
118150
experiments.features.forEach((exp) => {
119-
// Filter out experiments groups that are not from the Python extension.
120-
if (exp.toLowerCase().startsWith('python')) {
151+
// Filter out experiment groups that are not from the Python extension.
152+
// Filter out experiment groups that are not already opted out or opted into.
153+
if (
154+
exp.toLowerCase().startsWith('python') &&
155+
!this._optOutFrom.includes(exp) &&
156+
!this._optInto.includes(exp)
157+
) {
121158
this.output.appendLine(Experiments.inGroup().format(exp));
122159
}
123160
});

src/client/common/utils/localize.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export namespace Http {
234234
}
235235
export namespace Experiments {
236236
export const inGroup = localize('Experiments.inGroup', "User belongs to experiment group '{0}'");
237+
export const optedOutOf = localize('Experiments.optedOutOf', "User opted out of experiment group '{0}'");
237238
}
238239
export namespace Interpreters {
239240
export const loading = localize('Interpreters.LoadingInterpreters', 'Loading Python Interpreters');

0 commit comments

Comments
 (0)