Skip to content

Commit

Permalink
Fix panic in query-frontend when combining results (#3683)
Browse files Browse the repository at this point in the history
* Fix panic in query-frontend when combining results

* chlog
  • Loading branch information
mapno authored May 16, 2024
1 parent c8840f8 commit 805b3f5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* [BUGFIX] Use os path separator to split blocks path. [#3552](https://github.com/grafana/tempo/issues/3552) (@teyyubismayil)
* [BUGFIX] Correctly parse traceql queries with > 1024 character attribute names or static values. [#3571](https://github.com/grafana/tempo/issues/3571) (@joe-elliott)
* [BUGFIX] Fix span-metrics' subprocessors bug that applied wrong configs when running multiple tenants. [#3612](https://github.com/grafana/tempo/pull/3612) (@mapno)
* [BUGFIX] Fix panic in query-frontend when combining results [#3683](https://github.com/grafana/tempo/pull/3683) (@mapno)

## v2.4.2

Expand Down
3 changes: 3 additions & 0 deletions pkg/traceql/combine.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func combineSearchResults(existing *tempopb.TraceSearchMetadata, incoming *tempo
existingStats, ok := existing.ServiceStats[service]
if !ok {
existingStats = &tempopb.ServiceStats{}
if existing.ServiceStats == nil {
existing.ServiceStats = make(map[string]*tempopb.ServiceStats)
}
existing.ServiceStats[service] = existingStats
}
existingStats.SpanCount = max(existingStats.SpanCount, incomingStats.SpanCount)
Expand Down
20 changes: 20 additions & 0 deletions pkg/traceql/combine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ func TestCombineResults(t *testing.T) {
},
},
},
{
name: "existing ServiceStats is nil doesn't panic",
existing: &tempopb.TraceSearchMetadata{},
new: &tempopb.TraceSearchMetadata{
ServiceStats: map[string]*tempopb.ServiceStats{
"service1": {
SpanCount: 3,
ErrorCount: 2,
},
},
},
expected: &tempopb.TraceSearchMetadata{
ServiceStats: map[string]*tempopb.ServiceStats{
"service1": {
SpanCount: 3,
ErrorCount: 2,
},
},
},
},
}

for _, tc := range tcs {
Expand Down

0 comments on commit 805b3f5

Please sign in to comment.