Skip to content

Commit 8733975

Browse files
Send telemetry when experiment service is ready. (microsoft#17012)
* Send telemetry when experiment service is ready. * Update tests * Update src/client/telemetry/index.ts Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
1 parent 5cef5e1 commit 8733975

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

news/3 Code Health/17011.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add telemetry sending time it took to load data from experiment service.

src/client/common/experiments/service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export class ExperimentService implements IExperimentService {
8181

8282
public async activate(): Promise<void> {
8383
if (this.experimentationService) {
84+
const initStart = Date.now();
8485
await this.experimentationService.initializePromise;
8586

8687
const experiments = this.globalState.get<{ features: string[] }>(EXP_MEMENTO_KEY, { features: [] });
@@ -96,6 +97,7 @@ export class ExperimentService implements IExperimentService {
9697
// `overrideInMemoryFeatures` was always passed in as `false`. So, the experiment
9798
// states did not change mid way.
9899
await this.experimentationService.initialFetch;
100+
sendTelemetryEvent(EventName.PYTHON_EXPERIMENTS_INIT_PERFORMANCE, Date.now() - initStart);
99101
}
100102
}
101103
sendOptInOptOutTelemetry(this._optInto, this._optOutFrom, this.appEnvironment.packageJson);

src/client/telemetry/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export enum EventName {
7272
UNITTEST_RUN_ALL_FAILED = 'UNITTEST.RUN_ALL_FAILED',
7373
UNITTEST_DISABLED = 'UNITTEST.DISABLED',
7474

75+
PYTHON_EXPERIMENTS_INIT_PERFORMANCE = 'PYTHON_EXPERIMENTS_INIT_PERFORMANCE',
7576
PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS = 'PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS',
77+
7678
EXTENSION_SURVEY_PROMPT = 'EXTENSION_SURVEY_PROMPT',
7779
JOIN_MAILING_LIST_PROMPT_DISPLAYED = 'JOIN_MAILING_LIST_PROMPT_DISPLAYED',
7880
JOIN_MAILING_LIST_PROMPT = 'JOIN_MAILING_LIST_PROMPT',

src/client/telemetry/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,10 @@ export interface IEventNamePropertyMapping {
12681268
* This event also has a measure, "resultLength", which records the number of completions provided.
12691269
*/
12701270
[EventName.PYTHON_LANGUAGE_SERVER_REQUEST]: unknown;
1271+
/**
1272+
* Telemetry event sent when the experiments service is initialized for the first time.
1273+
*/
1274+
[EventName.PYTHON_EXPERIMENTS_INIT_PERFORMANCE]: unknown;
12711275
/**
12721276
* Telemetry event sent once on session start with details on which experiments are opted into and opted out from.
12731277
*/

src/test/common/experiments/service.unit.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ suite('Experimentation service', () => {
431431

432432
await experimentService.activate();
433433

434-
assert.strictEqual(telemetryEvents.length, 1);
435-
assert.strictEqual(telemetryEvents[0].eventName, EventName.PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS);
436-
sinon.assert.calledOnce(sendTelemetryEventStub);
434+
assert.strictEqual(telemetryEvents.length, 2);
435+
assert.strictEqual(telemetryEvents[1].eventName, EventName.PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS);
436+
sinon.assert.calledTwice(sendTelemetryEventStub);
437437
});
438438

439439
test('The telemetry event properties should only be populated with valid experiment values', async () => {
@@ -465,7 +465,7 @@ suite('Experimentation service', () => {
465465

466466
await experimentService.activate();
467467

468-
const { properties } = telemetryEvents[0];
468+
const { properties } = telemetryEvents[1];
469469
assert.deepStrictEqual(properties, { optedInto: ['foo'], optedOutFrom: ['bar'] });
470470
});
471471

@@ -498,7 +498,7 @@ suite('Experimentation service', () => {
498498

499499
await experimentService.activate();
500500

501-
const { properties } = telemetryEvents[0];
501+
const { properties } = telemetryEvents[1];
502502
assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] });
503503
});
504504

@@ -554,7 +554,7 @@ suite('Experimentation service', () => {
554554

555555
await experimentService.activate();
556556

557-
const { properties } = telemetryEvents[0];
557+
const { properties } = telemetryEvents[1];
558558
assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] });
559559
});
560560

@@ -586,7 +586,7 @@ suite('Experimentation service', () => {
586586

587587
await experimentService.activate();
588588

589-
const { properties } = telemetryEvents[0];
589+
const { properties } = telemetryEvents[1];
590590
assert.deepStrictEqual(properties, { optedInto: [], optedOutFrom: [] });
591591
});
592592
});

0 commit comments

Comments
 (0)