This is an automated email from the ASF dual-hosted git repository. hanahmily pushed a commit to branch trace/sidx in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit bcb85ff5d30fcabeaa62925ee943c5fa5613f511 Author: Gao Hongtao <[email protected]> AuthorDate: Sun Aug 31 23:13:44 2025 +0800 Enhance trace query processing by adding tag filtering based on query criteria. Updated the executeQuery function to only include specified tags in the result. Added a new test case for filtering by service ID to validate the changes. --- banyand/query/processor.go | 5 ++++- test/cases/trace/data/data.go | 1 + test/cases/trace/trace.go | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/banyand/query/processor.go b/banyand/query/processor.go index 29dd1f35..3118f711 100644 --- a/banyand/query/processor.go +++ b/banyand/query/processor.go @@ -549,8 +549,11 @@ func (p *traceQueryProcessor) executeQuery(ctx context.Context, queryCriteria *t for i, spanBytes := range result.Spans { // Create trace tags from the result var traceTags []*modelv1.Tag - if result.Tags != nil { + if result.Tags != nil && len(queryCriteria.TagProjection) > 0 { for _, tag := range result.Tags { + if !slices.Contains(queryCriteria.TagProjection, tag.Name) { + continue + } if i < len(tag.Values) { traceTags = append(traceTags, &modelv1.Tag{ Key: tag.Name, diff --git a/test/cases/trace/data/data.go b/test/cases/trace/data/data.go index 1ad03a42..e35751eb 100644 --- a/test/cases/trace/data/data.go +++ b/test/cases/trace/data/data.go @@ -112,6 +112,7 @@ var VerifyFn = func(innerGm gm.Gomega, sharedContext helpers.SharedContext, args return err.Error() } var y []byte + // TODO: it lose tag values. y, err = yaml.JSONToYAML(j) if err != nil { return err.Error() diff --git a/test/cases/trace/trace.go b/test/cases/trace/trace.go index a4cc3e84..505da145 100644 --- a/test/cases/trace/trace.go +++ b/test/cases/trace/trace.go @@ -45,4 +45,5 @@ var _ = g.DescribeTable("Scanning Traces", func(args helpers.Args) { g.Entry("query by trace id", helpers.Args{Input: "eq_trace_id", Duration: 1 * time.Hour}), g.Entry("order by timestamp", helpers.Args{Input: "order_timestamp_desc", Duration: 1 * time.Hour}), g.Entry("order by duration", helpers.Args{Input: "order_duration_desc", Duration: 1 * time.Hour}), + g.Entry("filter by service id", helpers.Args{Input: "eq_service_order_timestamp_desc", Duration: 1 * time.Hour}), )
