Rewrite traces using rebatching - #4690
Merged
Merged
Conversation
stoewer
force-pushed
the
rewrite-traces
branch
from
February 14, 2025 05:14
8d0765b to
afd14bf
Compare
Signed-off-by: Joe Elliott <number101010@gmail.com>
Will be implemented in separate branch that will not be merged
The functions test.MakeBatch and test.MakeTrace* now create more unique ResourceSpans and ScopeSpans. This avoids unwanted rebatching in tests
Test data now has additional attributes on resource level that caused these tests to fail
stoewer
force-pushed
the
rewrite-traces
branch
from
February 16, 2025 23:55
afd14bf to
8ef32f6
Compare
stoewer
marked this pull request as ready for review
February 17, 2025 00:52
stoewer
requested review from
electron0zero,
ie-pham,
javiermolinar,
joe-elliott,
mapno,
mdisibio,
yvrhdn and
zalegrala
as code owners
February 17, 2025 00:52
stoewer
force-pushed
the
rewrite-traces
branch
from
February 17, 2025 02:49
1607e88 to
d50ab3c
Compare
joe-elliott
reviewed
Feb 19, 2025
joe-elliott
left a comment
Collaborator
There was a problem hiding this comment.
nice implementation. couple nits and only one "real" question.
thanks!
| } | ||
|
|
||
| // modify trace by rebatching spans and assigning nested set values | ||
| rebatchTrace(ot) |
Collaborator
There was a problem hiding this comment.
should we also call this after combining here-ish?
https://github.com/grafana/tempo/blob/main/tempodb/encoding/vparquet4/combiner.go#L139
we seem to have three things we do every time we build a trace:
- rebatch
- nested set model
- service stats
should we create some holistic function like "finalizeTrace" that accomplishes this? that way if we add more of this kind of processing we will have an easy place to put it?
func finalizeTrace() {
rebatch()
assignNestedSetModel()
...
}
| } | ||
|
|
||
| // preallocate a map and a slice to collect the indices of unique ResourceSpans and ScopeSpans | ||
| uniqueIndexes := make([]int, 0, max(len(trace.ResourceSpans), len(trace.ResourceSpans[0].ScopeSpans))) |
Collaborator
There was a problem hiding this comment.
took me a bit to figure out what you were using this. appreciate the effort on the in place alg. clean and well implemented.
mattdurham
pushed a commit
to mattdurham/tempo
that referenced
this pull request
Jun 18, 2026
* Implement span basic rebatching and 4to4 converter Signed-off-by: Joe Elliott <number101010@gmail.com> * Generated trace data with unique scope and resource spans The functions test.MakeBatch and test.MakeTrace* now create more unique ResourceSpans and ScopeSpans. This avoids unwanted rebatching in tests * Fix tests in spanmetrics processor Test data now has additional attributes on resource level that caused these tests to fail * Move rebatch code out of nested set function * Make parquetTraceToTempopbTrace() private * Add benchmark for testing traceToParquet() * make check-fmt * rebatchTrace() without allocating new slices for ResourceSpans and ScopeSpans * Fix bug with duplicated rs ans ss in rebatchTrace() * CHANGELOG.md * Add finalizeTrace() function * Call finalizeTrace() in combiner --------- Signed-off-by: Joe Elliott <number101010@gmail.com> Co-authored-by: Joe Elliott <number101010@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
Rebatch traces in order to remove redundant
ResourceSpansandScopeSpansto reduces the number of rows on resource and scope level. This has shown to speed up queries with matching resource attributes and also reduces the overall file size.Which issue(s) this PR fixes:
Fixes grafana/tempo-squad#548
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]