Skip to content

Commit

Permalink
Add missing string value length limits
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Dec 28, 2024
1 parent 9756822 commit ea32c2e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions exporter/clickhouselogsexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/ClickHouse/clickhouse-go/v2"
driver "github.com/ClickHouse/clickhouse-go/v2/lib/driver"
"github.com/SigNoz/signoz-otel-collector/internal/common"
"github.com/SigNoz/signoz-otel-collector/usage"
"github.com/SigNoz/signoz-otel-collector/utils"
"github.com/SigNoz/signoz-otel-collector/utils/fingerprint"
Expand Down Expand Up @@ -680,6 +681,16 @@ func (e *clickhouseLogsExporter) addAttrsToTagStatement(
) error {
unixMilli := (time.Now().UnixMilli() / 3600000) * 3600000
for i, v := range attrs.StringKeys {
if len(v) > common.MaxAttributeKeyLength {
e.logger.Debug("attribute key length exceeds the limit", zap.String("key", v))
continue
}

if len(attrs.StringValues[i]) > common.MaxAttributeValueLength {
e.logger.Debug("attribute value length exceeds the limit", zap.String("key", v))
continue
}

key := utils.MakeKeyForAttributeKeys(v, tagType, utils.TagDataTypeString)
if _, ok := shouldSkipKeys[key]; ok {
e.logger.Debug("key has been skipped", zap.String("key", key))
Expand Down
11 changes: 11 additions & 0 deletions exporter/clickhousetracesexporter/writerV3.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

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

if len(spanAttribute.Key) > common.MaxAttributeKeyLength {
w.logger.Debug("attribute key length exceeds the limit", zap.String("key", spanAttribute.Key))
continue
}

if len(spanAttribute.StringValue) > common.MaxAttributeValueLength {
w.logger.Debug("attribute value length exceeds the limit", zap.String("key", spanAttribute.Key))
continue
}

if spanAttribute.DataType == "string" {

if _, ok := shouldSkipKeys[v2Key]; !ok {
Expand Down
6 changes: 6 additions & 0 deletions internal/common/attribute_limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package common

const (
MaxAttributeKeyLength = 32
MaxAttributeValueLength = 256
)

0 comments on commit ea32c2e

Please sign in to comment.