Skip to content

Commit

Permalink
Change Casing And Naming of Invalid Tags
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Oct 12, 2024
1 parent 349e8df commit 9b1e665
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cmd/jaeger/internal/sanitizer/utf8.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
)

const (
invalidOperation = "InvalidOperationName"
invalidTagKey = "InvalidTagKey"
invalidSpanName = "invalid-span-name"
invalidTagKey = "invalid-tag-key"
)

// NewUTF8Sanitizer returns a sanitizer function that performs the following sanitizations
Expand Down Expand Up @@ -48,9 +48,9 @@ func sanitizeUTF8(traces ptrace.Traces) ptrace.Traces {

if !utf8.ValidString(span.Name()) {
sanitized := []byte(span.Name())
newVal := span.Attributes().PutEmptyBytes(invalidOperation)
newVal := span.Attributes().PutEmptyBytes(invalidSpanName)
newVal.Append(sanitized...)
span.SetName(invalidOperation)
span.SetName(invalidSpanName)
}

serviceName, ok := span.Attributes().Get(string(otelsemconv.ServiceNameKey))
Expand Down
8 changes: 4 additions & 4 deletions cmd/jaeger/internal/sanitizer/utf8_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var utf8EncodingTests = []struct {
name: "invalid key + valid value",
key: invalidUTF8(),
value: "value",
expectedKey: "InvalidTagKey",
expectedKey: "invalid-tag-key",
expectedValue: getBytesValueFromString(fmt.Sprintf("%s:value", invalidUTF8())),
},
{
Expand All @@ -56,7 +56,7 @@ var utf8EncodingTests = []struct {
name: "invalid key + invalid value",
key: invalidUTF8(),
value: invalidUTF8(),
expectedKey: "InvalidTagKey",
expectedKey: "invalid-tag-key",
expectedValue: getBytesValueFromString(fmt.Sprintf("%s:%s", invalidUTF8(), invalidUTF8())),
},
}
Expand Down Expand Up @@ -166,10 +166,10 @@ func TestUTF8Sanitizer_SanitizesInvalidSpanName(t *testing.T) {
Spans().
At(0).
Name()
require.Equal(t, "InvalidOperationName", name)
require.Equal(t, "invalid-span-name", name)
}

func TestUTF8Sanitizer_DoesNotSanitizInvalidSpanName(t *testing.T) {
func TestUTF8Sanitizer_DoesNotSanitizeInvalidSpanName(t *testing.T) {
traces := ptrace.NewTraces()
traces.
ResourceSpans().
Expand Down

0 comments on commit 9b1e665

Please sign in to comment.