-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of internal traces to jaeger proto translation #906
Improve performance of internal traces to jaeger proto translation #906
Conversation
Codecov Report
@@ Coverage Diff @@
## master #906 +/- ##
=======================================
Coverage 85.12% 85.12%
=======================================
Files 174 174
Lines 13376 13410 +34
=======================================
+ Hits 11386 11415 +29
- Misses 1543 1545 +2
- Partials 447 450 +3
Continue to review full report at Codecov.
|
if attrsCount == 0 { | ||
return &process | ||
} | ||
|
||
tags := make([]model.KeyValue, 0, attrsCount) | ||
process.Tags = appendTagsFromResourceAttributes(tags, attrs) | ||
return &process | ||
|
||
} | ||
|
||
func attributesToJaegerProtoTags(attrs pdata.AttributeMap) []model.KeyValue { | ||
func appendTagsFromResourceAttributes(dest []model.KeyValue, attrs pdata.AttributeMap) []model.KeyValue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler code:
process.Tags = appendTagsFromResourceAttributes(attrsCount, attrs)
return &process
func appendTagsFromResourceAttributes(attrs pdata.AttributeMap) []model.KeyValue {
if attrs.Cap() == 0 {
return nil
}
dest = make([]model.KeyValue, 0, attrs.Cap())
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not always the case that we can use attrs.Cap()
as capacity for tags slice, that's why I moved it outside
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, confused, why, because we allocate 1 extra element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The similar function appendTagsFromAttributes
needs to allocate more than attrs.Cap()
, I kept the same approach here as well
This PR also fixes an attribute mutation bug when "service.name" got removed from resource data structure
203d477
to
97fe397
Compare
@bogdandrutu PTAL |
…pen-telemetry#906) This PR also fixes an attribute mutation bug when "service.name" got removed from resource data structure
Benchmark results:
Before:
After: