Skip to content

Commit 83fbfdb

Browse files
authored
Fix telemetry about number of interpreters found (microsoft#15509)
1 parent cb98899 commit 83fbfdb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/client/interpreter/interpreterService.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
import { sleep } from '../common/utils/async';
2323
import { IServiceContainer } from '../ioc/types';
2424
import { EnvironmentType, PythonEnvironment } from '../pythonEnvironments/info';
25-
import { captureTelemetry } from '../telemetry';
25+
import { sendTelemetryEvent } from '../telemetry';
2626
import { EventName } from '../telemetry/constants';
2727
import {
2828
GetInterpreterOptions,
@@ -36,6 +36,7 @@ import {
3636
import { IVirtualEnvironmentManager } from './virtualEnvs/types';
3737
import { getInterpreterHash } from '../pythonEnvironments/discovery/locators/services/hashProvider';
3838
import { inDiscoveryExperiment } from '../common/experiments/helpers';
39+
import { StopWatch } from '../common/utils/stopWatch';
3940

4041
const EXPIRY_DURATION = 24 * 60 * 60 * 1000;
4142

@@ -137,9 +138,9 @@ export class InterpreterService implements Disposable, IInterpreterService {
137138
this.experimentsManager.sendTelemetryIfInExperiment(DeprecatePythonPath.control);
138139
}
139140

140-
@captureTelemetry(EventName.PYTHON_INTERPRETER_DISCOVERY, { locator: 'all' }, true)
141141
public async getInterpreters(resource?: Uri, options?: GetInterpreterOptions): Promise<PythonEnvironment[]> {
142142
let environments: PythonEnvironment[] = [];
143+
const stopWatch = new StopWatch();
143144
if (await inDiscoveryExperiment(this.experimentService)) {
144145
environments = await this.pyenvs.getInterpreters(resource, options);
145146
} else {
@@ -150,6 +151,11 @@ export class InterpreterService implements Disposable, IInterpreterService {
150151
environments = await locator.getInterpreters(resource, options);
151152
}
152153

154+
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_DISCOVERY, stopWatch.elapsedTime, {
155+
locator: 'all',
156+
interpreters: environments?.length ?? 0,
157+
});
158+
153159
await Promise.all(
154160
environments
155161
.filter((item) => !item.displayName)

0 commit comments

Comments
 (0)