in src/distributedTracingManager.ts [206:235]
private async promptForSamplingRate(prompt: string, defaultValue: number): Promise<number> {
if (defaultValue === undefined || defaultValue > 100 || defaultValue < 0) {
defaultValue = 100;
}
let samplingRate: string = await vscode.window.showInputBox({ prompt, value: defaultValue.toString(), ignoreFocusOut: true, validateInput: (value): string => {
if (value !== undefined) {
value = value.trim();
if (!value) {
return "Sampling rate cannot be empty";
}
const containsOnlyNumber = /^\d+$/.test(value);
const floatValue: number = parseFloat(value);
if (!containsOnlyNumber || !Number.isInteger(floatValue) || floatValue < 0 || floatValue > 100) {
return "Sampling rate should be an integer within [0, 100]";
}
return undefined;
} else {
return "Sampling rate cannot be empty";
}
}});
if (samplingRate !== undefined) {
samplingRate = samplingRate.trim();
const floatValue: number = parseFloat(samplingRate);
return floatValue;
}
return undefined;
}