mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-03 19:00:40 +08:00
Merge pull request #756 from SigNoz/feat/addHasErrorColumn
feat: add hasError tag in searchTraces response
This commit is contained in:
commit
61fb11a232
@ -1537,7 +1537,7 @@ func (r *ClickHouseReader) GetSpanFilters(ctx context.Context, queryParams *mode
|
||||
}
|
||||
}
|
||||
case "status":
|
||||
finalQuery := fmt.Sprintf("SELECT COUNT(*) as numErrors FROM %s WHERE timestamp >= ? AND timestamp <= ? AND ( ( has(tags, 'error:true') OR statusCode>=500 OR statusCode=2))", r.indexTable)
|
||||
finalQuery := fmt.Sprintf("SELECT COUNT(*) as numErrors FROM %s WHERE timestamp >= ? AND timestamp <= ? AND hasError = 1", r.indexTable)
|
||||
finalQuery += query
|
||||
var dBResponse []model.DBResponseErrors
|
||||
err := r.db.Select(&dBResponse, finalQuery, args...)
|
||||
@ -1582,16 +1582,16 @@ func getStatusFilters(query string, statusParams []string, excludeMap map[string
|
||||
if _, ok := excludeMap["status"]; ok {
|
||||
if len(statusParams) == 1 {
|
||||
if statusParams[0] == "error" {
|
||||
query += " AND ((NOT ( has(tags, 'error:true')) AND statusCode<500 AND statusCode!=2))"
|
||||
query += " AND hasError = 0"
|
||||
} else if statusParams[0] == "ok" {
|
||||
query += " AND ( ( has(tags, 'error:true') OR statusCode>=500 OR statusCode=2))"
|
||||
query += " AND hasError = 1"
|
||||
}
|
||||
}
|
||||
} else if len(statusParams) == 1 {
|
||||
if statusParams[0] == "error" {
|
||||
query += " AND ( ( has(tags, 'error:true') OR statusCode>=500 OR statusCode=2))"
|
||||
query += " AND hasError = 1"
|
||||
} else if statusParams[0] == "ok" {
|
||||
query += " AND ((NOT ( has(tags, 'error:true')) AND statusCode<500 AND statusCode!=2))"
|
||||
query += " AND hasError = 0"
|
||||
}
|
||||
}
|
||||
return query
|
||||
@ -2093,7 +2093,7 @@ func (r *ClickHouseReader) SearchTraces(ctx context.Context, traceId string) (*[
|
||||
|
||||
var searchScanReponses []model.SearchSpanReponseItem
|
||||
|
||||
query := fmt.Sprintf("SELECT timestamp, spanID, traceID, serviceName, name, kind, durationNano, tagsKeys, tagsValues, references, events FROM %s WHERE traceID=?", r.indexTable)
|
||||
query := fmt.Sprintf("SELECT timestamp, spanID, traceID, serviceName, name, kind, durationNano, tagsKeys, tagsValues, references, events, hasError FROM %s WHERE traceID=?", r.indexTable)
|
||||
|
||||
err := r.db.Select(&searchScanReponses, query, traceId)
|
||||
|
||||
@ -2106,7 +2106,7 @@ func (r *ClickHouseReader) SearchTraces(ctx context.Context, traceId string) (*[
|
||||
|
||||
searchSpansResult := []model.SearchSpansResult{
|
||||
model.SearchSpansResult{
|
||||
Columns: []string{"__time", "SpanId", "TraceId", "ServiceName", "Name", "Kind", "DurationNano", "TagsKeys", "TagsValues", "References", "Events"},
|
||||
Columns: []string{"__time", "SpanId", "TraceId", "ServiceName", "Name", "Kind", "DurationNano", "TagsKeys", "TagsValues", "References", "Events", "HasError"},
|
||||
Events: make([][]interface{}, len(searchScanReponses)),
|
||||
},
|
||||
}
|
||||
|
@ -179,6 +179,7 @@ type SearchSpanReponseItem struct {
|
||||
TagsKeys []string `db:"tagsKeys"`
|
||||
TagsValues []string `db:"tagsValues"`
|
||||
Events []string `db:"events"`
|
||||
HasError int32 `db:"hasError"`
|
||||
}
|
||||
|
||||
type OtelSpanRef struct {
|
||||
@ -214,7 +215,7 @@ func (item *SearchSpanReponseItem) GetValues() []interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
returnArray := []interface{}{int64(timeObj.UnixNano() / 1000000), item.SpanID, item.TraceID, item.ServiceName, item.Name, strconv.Itoa(int(item.Kind)), strconv.FormatInt(item.DurationNano, 10), item.TagsKeys, item.TagsValues, referencesStringArray, errorEvent}
|
||||
returnArray := []interface{}{int64(timeObj.UnixNano() / 1000000), item.SpanID, item.TraceID, item.ServiceName, item.Name, strconv.Itoa(int(item.Kind)), strconv.FormatInt(item.DurationNano, 10), item.TagsKeys, item.TagsValues, referencesStringArray, errorEvent, item.HasError}
|
||||
|
||||
return returnArray
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user