Skip to content

Commit

Permalink
removing appending "_truncated"
Browse files Browse the repository at this point in the history
  • Loading branch information
ie-pham committed Nov 25, 2024
1 parent f287c3e commit 7a2f10b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions modules/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,14 +629,14 @@ func requestsByTraceID(batches []*v1.ResourceSpans, userID string, spanCount, ma
func processAttributes(attributes []*v1_common.KeyValue, maxAttrSize int, count *int) {
for _, attr := range attributes {
if len(attr.Key) > maxAttrSize {
attr.Key = attr.Key[:maxAttrSize] + "_truncated"
attr.Key = attr.Key[:maxAttrSize]
*count++
}

switch value := attr.GetValue().Value.(type) {
case *v1_common.AnyValue_StringValue:
if len(value.StringValue) > maxAttrSize {
value.StringValue = value.StringValue[:maxAttrSize] + "_truncated"
value.StringValue = value.StringValue[:maxAttrSize]
*count++
}
default:
Expand Down
9 changes: 5 additions & 4 deletions modules/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,21 +753,21 @@ func TestProcessAttributes(t *testing.T) {
// find large resource attributes
for _, attr := range resource.Resource.Attributes {
if attr.Key == "long value" {
assert.Equal(t, longString[:maxAttrByte]+"_truncated", attr.Value.GetStringValue())
assert.Equal(t, longString[:maxAttrByte], attr.Value.GetStringValue())
}
if attr.Value.GetStringValue() == "long key" {
assert.Equal(t, longString[:maxAttrByte]+"_truncated", attr.Key)
assert.Equal(t, longString[:maxAttrByte], attr.Key)
}
}
// find large span attributes
for _, scope := range resource.ScopeSpans {
for _, span := range scope.Spans {
for _, attr := range span.Attributes {
if attr.Key == "long value" {
assert.Equal(t, longString[:maxAttrByte]+"_truncated", attr.Value.GetStringValue())
assert.Equal(t, longString[:maxAttrByte], attr.Value.GetStringValue())
}
if attr.Value.GetStringValue() == "long key" {
assert.Equal(t, longString[:maxAttrByte]+"_truncated", attr.Key)
assert.Equal(t, longString[:maxAttrByte], attr.Key)
}
}
}
Expand Down Expand Up @@ -796,6 +796,7 @@ func BenchmarkTestsByRequestID(b *testing.B) {
}

b.ResetTimer()
b.ReportAllocs()

for i := 0; i < b.N; i++ {
for _, blerg := range ils {
Expand Down

0 comments on commit 7a2f10b

Please sign in to comment.