Skip to content

Commit 05b146b

Browse files
committed
app/vlinsert/opentelemetry: skip attributes with missing key
While such attributes have no sense, it has been appeared that they can be sent by OTEL collector. See #869 (comment)
1 parent 9eba12d commit 05b146b

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

app/vlinsert/opentelemetry/opentelemetry_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ func TestPushProtobufRequest(t *testing.T) {
100100
"attributes": [
101101
{"key":"logger","value":{"stringValue":"context"}},
102102
{"key":"instance_id","value":{"intValue":10}},
103+
{"key":"","value":{"stringValue":"missing-key"}},
104+
{"key":"missing-value","value":{"stringValue":""}},
103105
{"key":"node_taints","value":{"keyValueList":{"values":
104106
[{"key":"role","value":{"stringValue":"dev"}},{"key":"cluster_load_percent","value":{"doubleValue":0.55}}]
105107
}}}
@@ -418,7 +420,9 @@ type keyValue struct {
418420
}
419421

420422
func (kv *keyValue) marshalProtobuf(mm *easyproto.MessageMarshaler) {
421-
mm.AppendString(1, kv.Key)
423+
if kv.Key != "" {
424+
mm.AppendString(1, kv.Key)
425+
}
422426
if kv.Value != nil {
423427
kv.Value.marshalProtobuf(mm.AppendMessage(2))
424428
}

app/vlinsert/opentelemetry/pb.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ func decodeKeyValue(src []byte, fs *logstorage.Fields, fb *fmtBuffer, fieldNameP
359359
return fmt.Errorf("cannot find Key in KeyValue: %w", err)
360360
}
361361
if !ok {
362-
return fmt.Errorf("key is missing in KeyValue")
362+
// Key is missing, skip it.
363+
// See https://github.com/VictoriaMetrics/VictoriaLogs/issues/869#issuecomment-3631307996
364+
return nil
363365
}
364366
fieldName := fb.formatSubFieldName(fieldNamePrefix, key)
365367

app/vlinsert/opentelemetry/pb_json.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ func decodeKeyValueToJSON(src []byte, dst *fastjson.Value, a *fastjson.Arena, fb
169169
return fmt.Errorf("cannot find Key in KeyValue: %w", err)
170170
}
171171
if !ok {
172-
return fmt.Errorf("key is missing in KeyValue")
172+
// Key is missing, skip it.
173+
// See https://github.com/VictoriaMetrics/VictoriaLogs/issues/869#issuecomment-3631307996
174+
return nil
173175
}
174176

175177
// Decode value

docs/victorialogs/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ according to the follosing docs:
2323

2424
* FEATURE: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): parse [`scope` inside ScopeLogs](https://github.com/open-telemetry/opentelemetry-proto/blob/a5f0eac5b802f7ae51dfe41e5116fe5548955e64/opentelemetry/proto/logs/v1/logs.proto#L72) and store it into [log fields](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) starting with `scope.` prefix. See [#826](https://github.com/VictoriaMetrics/VictoriaLogs/issues/826).
2525

26-
* BUGFIX: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): properly handle `null` values inside arrays. Previously, such arrays could cause a panic during ingestion. See [#869](https://github.com/VictoriaMetrics/VictoriaLogs/issues/869#issuecomment-3627177567).
26+
* BUGFIX: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): properly handle `null` values inside arrays. Previously, such arrays could cause a panic during ingestion. See [#869](https://github.com/VictoriaMetrics/VictoriaLogs/issues/869#issuecomment-3627177567). The issue has been introduced in [v1.40.0](https://github.com/VictoriaMetrics/VictoriaLogs/releases/tag/v1.40.0).
27+
* BUGFIX: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): properly skip attributes with missing key. See [this report](https://github.com/VictoriaMetrics/VictoriaLogs/issues/869#issuecomment-3631307996).
2728

2829
## [v1.40.0](https://github.com/VictoriaMetrics/VictoriaLogs/releases/tag/v1.40.0)
2930

0 commit comments

Comments
 (0)