Skip to content

Commit

Permalink
Use random sampling for sending Python environments API telemetry (mi…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj authored and wesm committed Apr 8, 2024
1 parent 40c64a6 commit bddb32f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions extensions/positron-python/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.001) {
// 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 bddb32f

Please sign in to comment.