From e418f60bfe2c05bc3f3414de21d3147a0561ca46 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 20 Mar 2024 13:05:13 -0700 Subject: [PATCH] Use random sampling for sending Python environments API telemetry --- src/client/environmentApi.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client/environmentApi.ts b/src/client/environmentApi.ts index cf70e188981d..311556b27ebf 100644 --- a/src/client/environmentApi.ts +++ b/src/client/environmentApi.ts @@ -134,10 +134,14 @@ export function buildEnvironmentApi( extensions .determineExtensionFromCallStack() .then((info) => { - sendTelemetryEvent(EventName.PYTHON_ENVIRONMENTS_API, undefined, { - apiName, - extensionId: info.extensionId, - }); + const p = Math.random(); + if (p <= 0.01) { + // Only send API telemetry 1% of the time, as it can be chatty. + sendTelemetryEvent(EventName.PYTHON_ENVIRONMENTS_API, undefined, { + apiName, + extensionId: info.extensionId, + }); + } traceVerbose(`Extension ${info.extensionId} accessed ${apiName} with args: ${JSON.stringify(args)}`); }) .ignoreErrors();