Skip to content
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

[jaeger-v2] Implement UTF-8 sanitizer for OTLP #6078

Merged
merged 19 commits into from
Oct 14, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

Which problem is this PR solving?

Description of the changes

How was this change tested?

  • Unit tests

Checklist

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Comment on lines 96 to 97
default:
sanitized = append(sanitized, []byte(v.Str())...)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to get a second set of eyes on this. In v1, we casted the value to a lossy string and converted it to its byte representation. Is just doing v.str() safe here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write unit tests for different types and we will found out.

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.93%. Comparing base (4beead7) to head (91d02c2).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6078   +/-   ##
=======================================
  Coverage   96.92%   96.93%           
=======================================
  Files         351      352    +1     
  Lines       16675    16720   +45     
=======================================
+ Hits        16162    16207   +45     
  Misses        329      329           
  Partials      184      184           
Flag Coverage Δ
badger_v1 7.98% <ø> (ø)
badger_v2 1.84% <ø> (ø)
cassandra-4.x-v1 15.75% <ø> (ø)
cassandra-4.x-v2 1.77% <ø> (ø)
cassandra-5.x-v1 15.75% <ø> (ø)
cassandra-5.x-v2 1.77% <ø> (ø)
elasticsearch-6.x-v1 18.95% <ø> (+0.01%) ⬆️
elasticsearch-7.x-v1 19.00% <ø> (-0.02%) ⬇️
elasticsearch-8.x-v1 19.19% <ø> (ø)
elasticsearch-8.x-v2 1.84% <ø> (ø)
grpc_v1 9.35% <ø> (-0.02%) ⬇️
grpc_v2 7.12% <ø> (ø)
kafka-v1 9.68% <ø> (ø)
kafka-v2 1.84% <ø> (ø)
memory_v2 1.84% <ø> (ø)
opensearch-1.x-v1 19.06% <ø> (+0.01%) ⬆️
opensearch-2.x-v1 19.06% <ø> (ø)
opensearch-2.x-v2 1.83% <ø> (-0.02%) ⬇️
tailsampling-processor 0.49% <ø> (ø)
unittests 95.74% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review October 12, 2024 20:29
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner October 12, 2024 20:29
@dosubot dosubot bot added the v2 label Oct 12, 2024
cmd/jaeger/internal/sanitizer/utf8.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/sanitizer/utf8.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/sanitizer/utf8.go Outdated Show resolved Hide resolved
cmd/jaeger/internal/sanitizer/utf8.go Show resolved Hide resolved
Comment on lines 96 to 97
default:
sanitized = append(sanitized, []byte(v.Str())...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write unit tests for different types and we will found out.

cmd/jaeger/internal/sanitizer/utf8_test.go Show resolved Hide resolved
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>

for k, v := range invalidKeys {
sanitized := []byte(k + ":")
switch v.Type() {
Copy link
Collaborator Author

@mahadzaryab1 mahadzaryab1 Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the godoc of Type()

// Type returns the type of the value for this Value.
// Calling this function on zero-initialized Value will cause a panic.

Can we run into a situation where we call this on a zero-initialized value in the regular exporter flow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, but I think we wouldn't reach that point.

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
}

attributes.Remove(k)
newVal := attributes.PutEmptyBytes(invalidTagKey)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we have two attributes with invalid keys?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for flagging! added in a bit to enumerate the keys - let me know what you think

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
@yurishkuro yurishkuro added the changelog:exprimental Change to an experimental part of the code label Oct 14, 2024
@yurishkuro yurishkuro merged commit c7e9f3d into jaegertracing:main Oct 14, 2024
49 of 50 checks passed
chahatsagarmain pushed a commit to chahatsagarmain/jaeger that referenced this pull request Oct 23, 2024
## Which problem is this PR solving?
- Resolves jaegertracing#5545 

## Description of the changes
- Continuation of jaegertracing#6077 to
implement the UTF-8 sanitizer to operate on OTLP data.

## How was this change tested?
- Unit tests 

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
@mahadzaryab1 mahadzaryab1 deleted the utf8-sanitizer branch October 31, 2024 22:35
yurishkuro added a commit to yurishkuro/jaeger that referenced this pull request Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:exprimental Change to an experimental part of the code v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transform v1 sanitizers into processors or something else
2 participants