Skip to content

Commit

Permalink
replace switch with if-statement
Browse files Browse the repository at this point in the history
  • Loading branch information
rubvs committed Aug 14, 2024
1 parent d03a251 commit d71a8df
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions input/otlp/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,23 +539,19 @@ func setLabel(key string, event *modelpb.APMEvent, v interface{}) {
value := make([]string, len(v))
for i := range v {
// Ensure that the array is homogeneous
switch r := v[i].(type) {
case string:
// Drop value that is not OTEL supported: https://opentelemetry.io/docs/specs/otel/common/
if r, ok := v[i].(string); ok {
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 {
// Ensure that the array is homogeneous
switch r := v[i].(type) {
case float64:
// Drop value that is not OTEL supported: https://opentelemetry.io/docs/specs/otel/common/
if r, ok := v[i].(float64); ok {
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 d71a8df

Please sign in to comment.