Skip to content

Commit

Permalink
use rune count instead of byte count in string
Browse files Browse the repository at this point in the history
  • Loading branch information
rubvs committed Sep 13, 2024
1 parent 72575f1 commit d4fd54c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion input/otlp/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"encoding/hex"
"strings"
"time"
"unicode/utf8"

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
Expand Down Expand Up @@ -256,7 +257,7 @@ func sanitizeDataStream(k string) string {
if k[0] == '_' || k[0] == '+' {
k = k[1:]
}
if len(k) > MaxDataStreamRunes {
if utf8.RuneCountInString(k) > MaxDataStreamRunes {
return string([]rune(k)[:MaxDataStreamRunes])
}
return k
Expand Down

0 comments on commit d4fd54c

Please sign in to comment.