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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

mahadzaryab1
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

How was this change tested?

  • Unit tests

Checklist

Comment on lines +96 to +97
default:
sanitized = append(sanitized, []byte(v.Str())...)
Copy link
Contributor 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.94%. Comparing base (4beead7) to head (349e8df).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6078      +/-   ##
==========================================
+ Coverage   96.92%   96.94%   +0.02%     
==========================================
  Files         351      352       +1     
  Lines       16675    16724      +49     
==========================================
+ Hits        16162    16213      +51     
+ Misses        329      328       -1     
+ Partials      184      183       -1     
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.20% <ø> (+0.01%) ⬆️
elasticsearch-8.x-v2 1.84% <ø> (ø)
grpc_v1 9.36% <ø> (ø)
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.84% <ø> (ø)
tailsampling-processor 0.49% <ø> (ø)
unittests 95.76% <100.00%> (+0.02%) ⬆️

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
)

const (
invalidOperation = "InvalidOperationName"
Copy link
Member

Choose a reason for hiding this comment

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

Values don't match kebub-case from the other sanitizer

)

const (
invalidOperation = "InvalidOperationName"
Copy link
Member

Choose a reason for hiding this comment

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

Also let's use "span name" term, not operation

span.SetName(invalidOperation)
}

serviceName, ok := span.Attributes().Get(string(otelsemconv.ServiceNameKey))
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to special case service.name? Wouldn't it be handled generically as all other attributes?

Copy link
Member

Choose a reason for hiding this comment

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

Also, service name is supposed to be defined at the resource level, not at individual spans.


if v.Type() == pcommon.ValueTypeStr && !utf8.ValidString(v.Str()) {
sanitized := []byte(v.Str())
newVal := attributes.PutEmptyBytes(k)
Copy link
Member

Choose a reason for hiding this comment

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

This contradicts the comment above about modifying the attributes while iterating over them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yurishkuro the comment was for modifying the keys of the map. is there anything wrong with modifying the value associated with a key?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know, the command is put(), it may depend on the implementation.

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.

var utf8EncodingTests = []struct {
name string
key string
value string
Copy link
Member

Choose a reason for hiding this comment

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

It seems if your tests only allow string values you cannot test other attribute types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transform v1 sanitizers into processors or something else
2 participants