-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Fix] Prevent panic when sanitizing read-only traces with multiple exporters #7245
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
Conversation
e00cbae to
c771901
Compare
|
|
||
| var workingTraces ptrace.Traces | ||
|
|
||
| canModify := true |
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.
there is IsReadOnly function, why do we need to test via panic?
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.
my bad, I've refactored it
| span := spans.At(k) | ||
| if spanNeedsDurationSanitization(span) { | ||
| needsModification = true | ||
| break |
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.
this only breaks out of the inner loop, you need to use a label at the outer loop and break outerloop. Or move the check to a function and return true
| workingResourceSpans := workingTraces.ResourceSpans() | ||
| for i := 0; i < workingResourceSpans.Len(); i++ { | ||
| resourceSpan := workingResourceSpans.At(i) |
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.
I think you can simplify using iterators
| workingResourceSpans := workingTraces.ResourceSpans() | |
| for i := 0; i < workingResourceSpans.Len(); i++ { | |
| resourceSpan := workingResourceSpans.At(i) | |
| for resourceSpan := range workingTraces.ResourceSpans().All() { |
internal/jptrace/sanitizer/utf8.go
Outdated
|
|
||
| func attributesNeedUTF8Sanitization(attributes pcommon.Map) bool { | ||
| needsSanitization := false | ||
| attributes.Range(func(k string, v pcommon.Value) bool { |
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.
could you use iterator here?
for k, v := attributes.All()
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7245 +/- ##
==========================================
- Coverage 96.20% 96.17% -0.04%
==========================================
Files 369 370 +1
Lines 22098 22290 +192
==========================================
+ Hits 21260 21437 +177
- Misses 626 638 +12
- Partials 212 215 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Both DCO checks are failing. My recommendation is to squash all commits into one and make sure it is signed correctly. See CONTRIBUTING for help. |
…porters Implement copy-on-write approach for all sanitizers: - Check if modifications are needed before attempting changes - Return original traces if no sanitization required - Test mutability and create a copy if data is read-only - Apply modifications to the working copy instead of original data --------- Signed-off-by: Victor Nguen <nguen-victor@yandex.ru>
|
Thanks, I squashed the commits. DCO passed. |
Which problem is this PR solving?
Description of the changes
Implement copy-on-write approach for all sanitizers:
How was this change tested?
Checklist
jaeger:make lint testjaeger-ui:npm run lintandnpm run test