Skip to content

Commit

Permalink
drop invalid array elements in otlp payload
Browse files Browse the repository at this point in the history
  • Loading branch information
rubvs committed Aug 14, 2024
1 parent 82e7526 commit d03a251
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions input/otlp/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit d03a251

Please sign in to comment.