Procházet zdrojové kódy

优化接口数字视图与错误分布对齐问题

路佳明 před 3 týdny
rodič
revize
f6786d86a1

+ 9 - 4
app/observe/service/event.go

@@ -114,12 +114,17 @@ func (e *Event) EventStatistic(c *dto.EventStatisticReq, result *[]dto.EventStat
 				Group("start_time").Order("start_time").Having("total>0").Find(result).Error
 		case "interface":
 			// 改为接口相关的错误分布,与请求总数*错误率对上
-			start := time.Unix(c.StartTime, 0).Truncate(time.Hour).Format(time.DateTime)
-			end := time.Unix(c.EndTime, 0).Truncate(time.Hour).Add(time.Hour).Format(time.DateTime)
+			// start := time.Unix(c.StartTime, 0).Truncate(time.Hour).Format(time.DateTime)
+			// end := time.Unix(c.EndTime, 0).Truncate(time.Hour).Add(time.Hour).Format(time.DateTime)
+			um := models.UrlMapping{}
+			err := e.Orm.Model(&models.UrlMapping{}).Where("id=?", c.SubconditionValue).First(&um).Error
+			if err != nil {
+				return err
+			}
 			return e.ChOrm.Debug().Model(&models.TracesURL{}).
 				Select("toStartOfFiveMinutes(Timestamp) as StartTime, count() as Total").
-				Where("Route=? or Path=?", c.SubconditionValue, c.SubconditionValue).
-				Where("StartTime>=? and StartTime<?", start, end).
+				Where("Route=? and Method=? and ServiceName=? and AppAlias=?", um.Url, um.Method, um.ServiceName, um.AppAlias).
+				Where("Timestamp>=? and Timestamp<?", c.StartTime, c.EndTime).
 				Where("StatusCode>=400").
 				Group("StartTime").Order("StartTime").Find(result).Error
 

+ 1 - 1
app/observe/service/urlmapping.go

@@ -1134,7 +1134,7 @@ func (s *UrlMapping) SubDigits(req *dto.UrlMappingSubDigitsReq, resp *dto.UrlMap
 		MedianDuration float64
 		MaxDuration    float64
 	}{}
-	db := s.ChOrm.Model(&models.TracesURL{}).
+	db := s.ChOrm.Model(&models.TracesURL{}).Debug().
 		Select("count() as Total, sum(if(StatusCode>=400, 1, 0)) as ErrorNum, quantile(0.5)(Duration)/1e6 as MedianDuration, max(Duration)/1e6 as MaxDuration").
 		// Where("Route like ?", um.Url+"%").Where("Method", um.Method).
 		// Where("ServiceName", um.ServiceName).