chore: fix error rate (#7701)

Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
This commit is contained in:
Shivanshu Raj Shrivastava 2025-04-23 01:56:37 +05:30 committed by GitHub
parent f3a1f3cc20
commit 365a3e250f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 84 additions and 12 deletions

View File

@ -5600,7 +5600,12 @@ func (aH *APIHandler) getDomainList(w http.ResponseWriter, r *http.Request) {
return return
} }
result = postprocess.TransformToTableForBuilderQueries(result, queryRangeParams) result, err = postprocess.PostProcessResult(result, queryRangeParams)
if err != nil {
apiErrObj := &model.ApiError{Typ: model.ErrorBadData, Err: err}
RespondError(w, apiErrObj, errQuriesByName)
return
}
if !thirdPartyQueryRequest.ShowIp { if !thirdPartyQueryRequest.ShowIp {
result = thirdPartyApi.FilterResponse(result) result = thirdPartyApi.FilterResponse(result)

View File

@ -58,6 +58,7 @@ func BuildDomainList(thirdPartyApis *ThirdPartyApis) (*v3.QueryRangeParamsV3, er
builderQueries["endpoints"] = &v3.BuilderQuery{ builderQueries["endpoints"] = &v3.BuilderQuery{
QueryName: "endpoints", QueryName: "endpoints",
Legend: "endpoints",
DataSource: v3.DataSourceTraces, DataSource: v3.DataSourceTraces,
StepInterval: defaultStepInterval, StepInterval: defaultStepInterval,
AggregateOperator: v3.AggregateOperatorCountDistinct, AggregateOperator: v3.AggregateOperatorCountDistinct,
@ -92,10 +93,13 @@ func BuildDomainList(thirdPartyApis *ThirdPartyApis) (*v3.QueryRangeParamsV3, er
}, },
}, thirdPartyApis.GroupBy), }, thirdPartyApis.GroupBy),
ReduceTo: v3.ReduceToOperatorAvg, ReduceTo: v3.ReduceToOperatorAvg,
ShiftBy: 0,
IsAnomaly: false,
} }
builderQueries["lastseen"] = &v3.BuilderQuery{ builderQueries["lastseen"] = &v3.BuilderQuery{
QueryName: "lastseen", QueryName: "lastseen",
Legend: "lastseen",
DataSource: v3.DataSourceTraces, DataSource: v3.DataSourceTraces,
StepInterval: defaultStepInterval, StepInterval: defaultStepInterval,
AggregateOperator: v3.AggregateOperatorMax, AggregateOperator: v3.AggregateOperatorMax,
@ -128,10 +132,13 @@ func BuildDomainList(thirdPartyApis *ThirdPartyApis) (*v3.QueryRangeParamsV3, er
}, },
}, thirdPartyApis.GroupBy), }, thirdPartyApis.GroupBy),
ReduceTo: v3.ReduceToOperatorAvg, ReduceTo: v3.ReduceToOperatorAvg,
ShiftBy: 0,
IsAnomaly: false,
} }
builderQueries["rps"] = &v3.BuilderQuery{ builderQueries["rps"] = &v3.BuilderQuery{
QueryName: "rps", QueryName: "rps",
Legend: "rps",
DataSource: v3.DataSourceTraces, DataSource: v3.DataSourceTraces,
StepInterval: defaultStepInterval, StepInterval: defaultStepInterval,
AggregateOperator: v3.AggregateOperatorRate, AggregateOperator: v3.AggregateOperatorRate,
@ -164,17 +171,21 @@ func BuildDomainList(thirdPartyApis *ThirdPartyApis) (*v3.QueryRangeParamsV3, er
}, },
}, thirdPartyApis.GroupBy), }, thirdPartyApis.GroupBy),
ReduceTo: v3.ReduceToOperatorAvg, ReduceTo: v3.ReduceToOperatorAvg,
ShiftBy: 0,
IsAnomaly: false,
} }
builderQueries["error_rate"] = &v3.BuilderQuery{ builderQueries["error"] = &v3.BuilderQuery{
QueryName: "error_rate", QueryName: "error",
DataSource: v3.DataSourceTraces, DataSource: v3.DataSourceTraces,
StepInterval: defaultStepInterval, StepInterval: defaultStepInterval,
AggregateOperator: v3.AggregateOperatorRate, AggregateOperator: v3.AggregateOperatorCountDistinct,
AggregateAttribute: v3.AttributeKey{ AggregateAttribute: v3.AttributeKey{
Key: "", Key: "span_id",
DataType: v3.AttributeKeyDataTypeString,
IsColumn: true,
}, },
TimeAggregation: v3.TimeAggregationRate, TimeAggregation: v3.TimeAggregationCountDistinct,
SpaceAggregation: v3.SpaceAggregationSum, SpaceAggregation: v3.SpaceAggregationSum,
Filters: &v3.FilterSet{ Filters: &v3.FilterSet{
Operator: "AND", Operator: "AND",
@ -200,7 +211,7 @@ func BuildDomainList(thirdPartyApis *ThirdPartyApis) (*v3.QueryRangeParamsV3, er
}, },
}, thirdPartyApis.Filters), }, thirdPartyApis.Filters),
}, },
Expression: "error_rate", Expression: "error",
GroupBy: getGroupBy([]v3.AttributeKey{ GroupBy: getGroupBy([]v3.AttributeKey{
{ {
Key: "net.peer.name", Key: "net.peer.name",
@ -209,10 +220,55 @@ func BuildDomainList(thirdPartyApis *ThirdPartyApis) (*v3.QueryRangeParamsV3, er
}, },
}, thirdPartyApis.GroupBy), }, thirdPartyApis.GroupBy),
ReduceTo: v3.ReduceToOperatorAvg, ReduceTo: v3.ReduceToOperatorAvg,
Disabled: true,
ShiftBy: 0,
IsAnomaly: false,
}
builderQueries["total_span"] = &v3.BuilderQuery{
QueryName: "total_span",
DataSource: v3.DataSourceTraces,
StepInterval: defaultStepInterval,
AggregateOperator: v3.AggregateOperatorCountDistinct,
AggregateAttribute: v3.AttributeKey{
Key: "span_id",
DataType: v3.AttributeKeyDataTypeString,
IsColumn: true,
},
TimeAggregation: v3.TimeAggregationCountDistinct,
SpaceAggregation: v3.SpaceAggregationSum,
Filters: &v3.FilterSet{
Operator: "AND",
Items: getFilterSet([]v3.FilterItem{
{
Key: v3.AttributeKey{
Key: "http.url",
DataType: v3.AttributeKeyDataTypeString,
IsColumn: false,
Type: v3.AttributeKeyTypeTag,
},
Operator: v3.FilterOperatorExists,
Value: "",
},
}, thirdPartyApis.Filters),
},
Expression: "total_span",
GroupBy: getGroupBy([]v3.AttributeKey{
{
Key: "net.peer.name",
DataType: v3.AttributeKeyDataTypeString,
Type: v3.AttributeKeyTypeTag,
},
}, thirdPartyApis.GroupBy),
ReduceTo: v3.ReduceToOperatorAvg,
Disabled: true,
ShiftBy: 0,
IsAnomaly: false,
} }
builderQueries["p99"] = &v3.BuilderQuery{ builderQueries["p99"] = &v3.BuilderQuery{
QueryName: "p99", QueryName: "p99",
Legend: "p99",
DataSource: v3.DataSourceTraces, DataSource: v3.DataSourceTraces,
StepInterval: defaultStepInterval, StepInterval: defaultStepInterval,
AggregateOperator: v3.AggregateOperatorP99, AggregateOperator: v3.AggregateOperatorP99,
@ -247,6 +303,17 @@ func BuildDomainList(thirdPartyApis *ThirdPartyApis) (*v3.QueryRangeParamsV3, er
}, },
}, thirdPartyApis.GroupBy), }, thirdPartyApis.GroupBy),
ReduceTo: v3.ReduceToOperatorAvg, ReduceTo: v3.ReduceToOperatorAvg,
ShiftBy: 0,
IsAnomaly: false,
}
builderQueries["error_rate"] = &v3.BuilderQuery{
QueryName: "error_rate",
Expression: "(error/total_span)*100",
Legend: "error_rate",
Disabled: false,
ShiftBy: 0,
IsAnomaly: false,
} }
compositeQuery := &v3.CompositeQuery{ compositeQuery := &v3.CompositeQuery{