Skip to content

Commit

Permalink
Fix decoding issue (#158) (#159)
Browse files Browse the repository at this point in the history
Attributes with empty keys were already ignored, but not attributes with
no value. In this PR, I consider an attribute with no value as malformed
or invalid, so they are ignored.
Let me know if this is not the behavior you expected.

Closes: #158
  • Loading branch information
lquerel committed Mar 26, 2024
1 parent df6b3e8 commit 795302c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
11 changes: 0 additions & 11 deletions go.mod
Expand Up @@ -57,14 +57,3 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)











1 change: 1 addition & 0 deletions pkg/benchmark/compression.go
Expand Up @@ -23,6 +23,7 @@ import (
)

const CompressionTypeZstd = "zstd"
const CompressionTypeNone = ""

type CompressionAlgorithm interface {
fmt.Stringer
Expand Down
1 change: 1 addition & 0 deletions pkg/benchmark/dataset/real_logs_dataset.go
Expand Up @@ -26,6 +26,7 @@ import (
"go.opentelemetry.io/collector/pdata/plog/plogotlp"

"github.com/klauspost/compress/zstd"

"github.com/open-telemetry/otel-arrow/pkg/benchmark"
"github.com/open-telemetry/otel-arrow/pkg/benchmark/stats"
)
Expand Down
13 changes: 7 additions & 6 deletions pkg/otel/common/arrow/attributes.go
Expand Up @@ -168,10 +168,11 @@ func (b *AttributesBuilder) Append(attrs pcommon.Map) error {
return b.builder.Append(attrs.Len(), func() error {
var err error
attrs.Range(func(key string, v pcommon.Value) bool {
if key == "" {
// Skip entries with empty keys
// Attribute without key or without value are ignored.
if key == "" || v.Type() == pcommon.ValueTypeEmpty {
return true
}

b.kb.AppendNonEmpty(key)
return b.ib.Append(&v) == nil
})
Expand Down Expand Up @@ -236,8 +237,8 @@ func (c *Attributes16Accumulator) AppendWithID(parentID uint16, attrs pcommon.Ma
}

attrs.Range(func(key string, v pcommon.Value) bool {
if key == "" {
// Skip entries with empty keys
// Attribute without key or without value are ignored.
if key == "" || v.Type() == pcommon.ValueTypeEmpty {
return true
}

Expand Down Expand Up @@ -290,8 +291,8 @@ func (c *Attributes32Accumulator) Append(ID uint32, attrs pcommon.Map) error {
}

attrs.Range(func(key string, v pcommon.Value) bool {
if key == "" {
// Skip entries with empty keys
// Attribute without key or without value are ignored.
if key == "" || v.Type() == pcommon.ValueTypeEmpty {
return true
}

Expand Down
4 changes: 3 additions & 1 deletion tools/logs_benchmark/main.go
Expand Up @@ -81,6 +81,7 @@ func main() {
// Compare the performance for each input file
for i := range inputFiles {
var ds dataset.LogsDataset
var compression = benchmark.CompressionTypeZstd

inputFile := inputFiles[i]
compressionAlgo := benchmark.Zstd()
Expand All @@ -93,6 +94,7 @@ func main() {
// in case formatFlag was not passed
if strings.HasSuffix(inputFile, ".json") {
*formatFlag = "json"
compression = benchmark.CompressionTypeNone
} else if strings.HasSuffix(inputFile, ".pb") {
*formatFlag = "proto"
}
Expand All @@ -101,7 +103,7 @@ func main() {
if strings.HasSuffix(inputFile, ".csv") {
ds = CsvToLogsDataset(inputFile)
} else {
rds := dataset.NewRealLogsDataset(inputFiles[i], benchmark.CompressionTypeZstd, *formatFlag)
rds := dataset.NewRealLogsDataset(inputFiles[i], compression, *formatFlag)
//rds.Resize(10)
ds = rds
}
Expand Down

0 comments on commit 795302c

Please sign in to comment.