@@ -24,7 +24,7 @@ import (
24
24
"strings"
25
25
26
26
"go.opentelemetry.io/collector/pdata/pcommon"
27
- semconv "go.opentelemetry.io/collector/semconv/v1.5 .0"
27
+ semconv "go.opentelemetry.io/collector/semconv/v1.25 .0"
28
28
29
29
"github.com/elastic/apm-data/model/modelpb"
30
30
)
@@ -131,7 +131,7 @@ func translateResourceMetadata(resource pcommon.Resource, out *modelpb.APMEvent)
131
131
out .Container = modelpb .ContainerFromVTPool ()
132
132
}
133
133
out .Container .ImageName = truncate (v .Str ())
134
- case semconv . AttributeContainerImageTag :
134
+ case "container.image.tag" :
135
135
if out .Container == nil {
136
136
out .Container = modelpb .ContainerFromVTPool ()
137
137
}
@@ -185,6 +185,17 @@ func translateResourceMetadata(resource pcommon.Resource, out *modelpb.APMEvent)
185
185
out .Host = modelpb .HostFromVTPool ()
186
186
}
187
187
out .Host .Architecture = truncate (v .Str ())
188
+ case semconv .AttributeHostIP :
189
+ if out .Host == nil {
190
+ out .Host = modelpb .HostFromVTPool ()
191
+ }
192
+ out .Host .Ip = pSliceToType [* modelpb.IP ](v .Slice (), func (v pcommon.Value ) (* modelpb.IP , bool ) {
193
+ ip , err := modelpb .ParseIP (v .Str ())
194
+ if err != nil {
195
+ return nil , false
196
+ }
197
+ return ip , true
198
+ })
188
199
189
200
// process.*
190
201
case semconv .AttributeProcessPID :
@@ -479,11 +490,19 @@ func ifaceAttributeValue(v pcommon.Value) interface{} {
479
490
}
480
491
481
492
func ifaceAttributeValueSlice (slice pcommon.Slice ) []interface {} {
482
- values := make ([]interface {}, slice .Len ())
483
- for i := range values {
484
- values [i ] = ifaceAttributeValue (slice .At (i ))
493
+ return pSliceToType [interface {}](slice , func (v pcommon.Value ) (interface {}, bool ) {
494
+ return ifaceAttributeValue (v ), true
495
+ })
496
+ }
497
+
498
+ func pSliceToType [T any ](slice pcommon.Slice , f func (pcommon.Value ) (T , bool )) []T {
499
+ result := make ([]T , 0 , slice .Len ())
500
+ for i := 0 ; i < slice .Len (); i ++ {
501
+ if v , ok := f (slice .At (i )); ok {
502
+ result = append (result , v )
503
+ }
485
504
}
486
- return values
505
+ return result
487
506
}
488
507
489
508
// initEventLabels initializes an event-specific labels from an event.
0 commit comments