From 05b775c90d9362b8fe9fb973f5571da3cb29e6f1 Mon Sep 17 00:00:00 2001 From: Ruben van Staden Date: Tue, 13 Aug 2024 13:32:24 -0400 Subject: [PATCH] drop invalid array elements in otlp payload --- input/otlp/metadata.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/input/otlp/metadata.go b/input/otlp/metadata.go index 9d864880..82c47226 100644 --- a/input/otlp/metadata.go +++ b/input/otlp/metadata.go @@ -538,13 +538,25 @@ func setLabel(key string, event *modelpb.APMEvent, v interface{}) { case string: value := make([]string, len(v)) for i := range v { - value[i] = v[i].(string) + // Ensure that the array is homogeneous + switch r := v[i].(type) { + case string: + value[i] = r + default: + // Drop value that is not OTEL supported: https://opentelemetry.io/docs/specs/otel/common/ + } } modelpb.Labels(event.Labels).SetSlice(key, value) case float64: value := make([]float64, len(v)) for i := range v { - value[i] = v[i].(float64) + // Ensure that the array is homogeneous + switch r := v[i].(type) { + case float64: + value[i] = r + default: + // Drop value that is not OTEL supported: https://opentelemetry.io/docs/specs/otel/common/ + } } modelpb.NumericLabels(event.NumericLabels).SetSlice(key, value) }