From e82f20793513d8612653a4e62ac0ba58f3af6114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Wed, 23 Nov 2022 20:23:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1API=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E6=97=B6=E4=BD=8E=E4=BA=8E=E4=B8=80=E5=8D=8A=E7=9A=84=E9=87=87?= =?UTF-8?q?=E6=A0=B7=E7=8E=87=E8=BF=94=E5=9B=9E=E6=80=BB=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/rpc/call_stat.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/rpc/call_stat.go b/internal/rpc/call_stat.go index faa15dc..4bfdc77 100644 --- a/internal/rpc/call_stat.go +++ b/internal/rpc/call_stat.go @@ -45,8 +45,13 @@ func (this *CallStat) Sum() (successPercent float64, avgCostSeconds float64) { this.locker.Lock() defer this.locker.Unlock() + var size = this.size + if size <= 0 { + size = 10 + } + var totalItems = len(this.items) - if totalItems == 0 { + if totalItems <= size/2 /** 低于一半的采样率,不计入统计 **/ { successPercent = 100 return }