in packages/logger-sls/src/factory/create-logger.ts [49:66]
function checkIfIgnore(sampling?: number, onceKey?: string): boolean {
// onBeforeSend 阻止发送
if (onBeforeSend && onBeforeSend(factoryOptions) === false) { // 不能 simplify to !onBeforeSend(factoryOptions)
return true;
}
// 只需要发送一次,已发送过,则忽略
if (onceKey && ONCE[onceKey]) {
return true;
}
// 采样,`(0, 1)` 开区间
if (typeof sampling === 'number' && sampling > 0 && sampling < 1) {
return Math.random() > sampling;
}
return false;
}