Skip to content

Commit

Permalink
Use random sampling for sending Python environments API telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Mar 20, 2024
1 parent b9109cf commit e418f60
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/client/environmentApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e418f60

Please sign in to comment.