Browse Source

异常优化:只要http请求和数据库相关的

路佳明 2 months ago
parent
commit
7cf5d06bd3
1 changed files with 2 additions and 2 deletions
  1. 2 2
      app/observe/service/event.go

+ 2 - 2
app/observe/service/event.go

@@ -116,7 +116,7 @@ func (e *Event) EventStatistic(c *dto.EventStatisticReq, result *[]dto.EventStat
 	}
 	db.Where("Timestamp >= ? AND Timestamp <= ?", c.StartTime, c.EndTime)
 	// db.Where("StatusCode = 'STATUS_CODE_ERROR' AND StatusMessage != '' AND StatusMessage != 'status code:0'")
-	db.Where("StatusCode='STATUS_CODE_ERROR' AND (ParentSpanId='' OR SpanAttributes['db.system'] != '')") // 要求 只要root span和数据库 两种异常
+	db.Where("StatusCode='STATUS_CODE_ERROR' AND ((SpanAttributes['http.method'] != '' and SpanAttributes['rpc.system']='') OR SpanAttributes['db.system'] != '')") // 要求 只要http请求 和数据库 两种异常
 	db.Group("FiveMinuteInterval")
 	if err := db.Order("FiveMinuteInterval, StatusMessageCount Desc").Find(&result).Error; err != nil {
 		return errors.Wrap(err, "计算范围时间内的异常失败")
@@ -149,7 +149,7 @@ func (e *Event) EventLists(c *dto.EventStatisticReq, result *[]dto.EventListsRes
 	}
 	db.Where("Timestamp >= ? AND Timestamp <= ?", c.StartTime, c.EndTime)
 	// db.Where("StatusCode = 'STATUS_CODE_ERROR' AND StatusMessage != '' AND StatusMessage != 'status code:0'")
-	db.Where("StatusCode='STATUS_CODE_ERROR' AND (ParentSpanId='' OR SpanAttributes['db.system'] != '')") // 要求 只要root span和数据库 两种异常
+	db.Where("StatusCode='STATUS_CODE_ERROR' AND ((SpanAttributes['http.method'] != '' and SpanAttributes['rpc.system']='') OR SpanAttributes['db.system'] != '')") // 要求 只要root span和数据库 两种异常
 	db.Group("substring(StatusMessage, 1, 15)")
 	db.Group("ServiceName")
 	if err := db.Order("StatusMessageCount DESC;").Find(&res).Error; err != nil {