Skip to content

Commit 81fcf8b

Browse files
authored
Add missing string value length limits (#494)
1 parent 9756822 commit 81fcf8b

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

exporter/clickhouselogsexporter/exporter.go

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
"github.com/ClickHouse/clickhouse-go/v2"
3030
driver "github.com/ClickHouse/clickhouse-go/v2/lib/driver"
31+
"github.com/SigNoz/signoz-otel-collector/internal/common"
3132
"github.com/SigNoz/signoz-otel-collector/usage"
3233
"github.com/SigNoz/signoz-otel-collector/utils"
3334
"github.com/SigNoz/signoz-otel-collector/utils/fingerprint"
@@ -680,6 +681,12 @@ func (e *clickhouseLogsExporter) addAttrsToTagStatement(
680681
) error {
681682
unixMilli := (time.Now().UnixMilli() / 3600000) * 3600000
682683
for i, v := range attrs.StringKeys {
684+
685+
if len(attrs.StringValues[i]) > common.MaxAttributeValueLength {
686+
e.logger.Debug("attribute value length exceeds the limit", zap.String("key", v))
687+
continue
688+
}
689+
683690
key := utils.MakeKeyForAttributeKeys(v, tagType, utils.TagDataTypeString)
684691
if _, ok := shouldSkipKeys[key]; ok {
685692
e.logger.Debug("key has been skipped", zap.String("key", key))

exporter/clickhousetracesexporter/writerV3.go

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"time"
99

1010
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
11+
"github.com/SigNoz/signoz-otel-collector/internal/common"
1112
"github.com/SigNoz/signoz-otel-collector/usage"
1213
"github.com/SigNoz/signoz-otel-collector/utils"
1314
"github.com/jellydator/ttlcache/v3"
@@ -214,6 +215,11 @@ func (w *SpanWriter) writeTagBatchV3(ctx context.Context, batchSpans []*SpanV3)
214215
v2Key := utils.MakeKeyForAttributeKeys(spanAttribute.Key, utils.TagType(spanAttribute.TagType), utils.TagDataType(spanAttribute.DataType))
215216
unixMilli := (int64(span.StartTimeUnixNano/1e6) / 3600000) * 3600000
216217

218+
if len(spanAttribute.StringValue) > common.MaxAttributeValueLength {
219+
w.logger.Debug("attribute value length exceeds the limit", zap.String("key", spanAttribute.Key))
220+
continue
221+
}
222+
217223
if spanAttribute.DataType == "string" {
218224

219225
if _, ok := shouldSkipKeys[v2Key]; !ok {

internal/common/attribute_limits.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package common
2+
3+
const (
4+
MaxAttributeKeyLength = 64
5+
MaxAttributeValueLength = 256
6+
)

0 commit comments

Comments
 (0)