@@ -12,6 +12,7 @@ import (
12
12
"go.opentelemetry.io/collector/component"
13
13
"go.opentelemetry.io/collector/consumer/consumertest"
14
14
"go.opentelemetry.io/collector/receiver/receivertest"
15
+ conventions "go.opentelemetry.io/collector/semconv/v1.6.1"
15
16
"go.uber.org/zap"
16
17
"go.uber.org/zap/zapcore"
17
18
"go.uber.org/zap/zaptest/observer"
@@ -270,7 +271,7 @@ func TestSyncMetadataAndEmitEntityEvents(t *testing.T) {
270
271
"otel.entity.interval" : int64 (7200000 ), // 2h in milliseconds
271
272
"otel.entity.type" : "k8s.pod" ,
272
273
"otel.entity.id" : map [string ]any {"k8s.pod.uid" : "pod0" },
273
- "otel.entity.attributes" : map [string ]any {"pod.creation_timestamp" : "0001-01-01T00:00:00Z" , "k8s.pod.phase" : "Unknown" , "k8s.namespace.name" : "test" , "k8s.pod.name" : "0" },
274
+ "otel.entity.attributes" : map [string ]any {"pod.creation_timestamp" : "0001-01-01T00:00:00Z" , "k8s.pod.phase" : "Unknown" , "k8s.namespace.name" : "test" , "k8s.pod.name" : "0" , conventions . AttributeK8SNodeName : "test-node" },
274
275
}
275
276
assert .Equal (t , expected , lr .Attributes ().AsRaw ())
276
277
assert .WithinRange (t , lr .Timestamp ().AsTime (), step1 , step2 )
@@ -324,7 +325,7 @@ func TestObjMetadata(t *testing.T) {
324
325
EntityType : "k8s.pod" ,
325
326
ResourceIDKey : "k8s.pod.uid" ,
326
327
ResourceID : "test-pod-0-uid" ,
327
- Metadata : allPodMetadata (map [string ]string {"k8s.pod.phase" : "Succeeded" , "k8s.pod.name" : "test-pod-0" , "k8s.namespace.name" : "test-namespace" }),
328
+ Metadata : allPodMetadata (map [string ]string {"k8s.pod.phase" : "Succeeded" , "k8s.pod.name" : "test-pod-0" , "k8s.namespace.name" : "test-namespace" , conventions . AttributeK8SNodeName : "test-node" }),
328
329
},
329
330
experimentalmetricmetadata .ResourceID ("container-id" ): {
330
331
EntityType : "container" ,
@@ -353,21 +354,22 @@ func TestObjMetadata(t *testing.T) {
353
354
Name : "test-statefulset-0" ,
354
355
UID : "test-statefulset-0-uid" ,
355
356
},
356
- }, testutils .NewPodWithContainer ("0" , & corev1.PodSpec {}, & corev1.PodStatus {Phase : corev1 .PodFailed , Reason : "Evicted" })),
357
+ }, testutils .NewPodWithContainer ("0" , & corev1.PodSpec {NodeName : "test-node" }, & corev1.PodStatus {Phase : corev1 .PodFailed , Reason : "Evicted" })),
357
358
want : map [experimentalmetricmetadata.ResourceID ]* metadata.KubernetesMetadata {
358
359
experimentalmetricmetadata .ResourceID ("test-pod-0-uid" ): {
359
360
EntityType : "k8s.pod" ,
360
361
ResourceIDKey : "k8s.pod.uid" ,
361
362
ResourceID : "test-pod-0-uid" ,
362
363
Metadata : allPodMetadata (map [string ]string {
363
- "k8s.workload.kind" : "StatefulSet" ,
364
- "k8s.workload.name" : "test-statefulset-0" ,
365
- "k8s.statefulset.name" : "test-statefulset-0" ,
366
- "k8s.statefulset.uid" : "test-statefulset-0-uid" ,
367
- "k8s.pod.phase" : "Failed" ,
368
- "k8s.pod.status_reason" : "Evicted" ,
369
- "k8s.pod.name" : "test-pod-0" ,
370
- "k8s.namespace.name" : "test-namespace" ,
364
+ "k8s.workload.kind" : "StatefulSet" ,
365
+ "k8s.workload.name" : "test-statefulset-0" ,
366
+ "k8s.statefulset.name" : "test-statefulset-0" ,
367
+ "k8s.statefulset.uid" : "test-statefulset-0-uid" ,
368
+ "k8s.pod.phase" : "Failed" ,
369
+ "k8s.pod.status_reason" : "Evicted" ,
370
+ "k8s.pod.name" : "test-pod-0" ,
371
+ "k8s.namespace.name" : "test-namespace" ,
372
+ conventions .AttributeK8SNodeName : "test-node" ,
371
373
}),
372
374
},
373
375
},
@@ -396,19 +398,20 @@ func TestObjMetadata(t *testing.T) {
396
398
}(),
397
399
resource : podWithAdditionalLabels (
398
400
map [string ]string {"k8s-app" : "my-app" },
399
- testutils .NewPodWithContainer ("0" , & corev1.PodSpec {}, & corev1.PodStatus {Phase : corev1 .PodRunning }),
401
+ testutils .NewPodWithContainer ("0" , & corev1.PodSpec {NodeName : "test-node" }, & corev1.PodStatus {Phase : corev1 .PodRunning }),
400
402
),
401
403
want : map [experimentalmetricmetadata.ResourceID ]* metadata.KubernetesMetadata {
402
404
experimentalmetricmetadata .ResourceID ("test-pod-0-uid" ): {
403
405
EntityType : "k8s.pod" ,
404
406
ResourceIDKey : "k8s.pod.uid" ,
405
407
ResourceID : "test-pod-0-uid" ,
406
408
Metadata : allPodMetadata (map [string ]string {
407
- "k8s.service.test-service" : "" ,
408
- "k8s-app" : "my-app" ,
409
- "k8s.pod.phase" : "Running" ,
410
- "k8s.namespace.name" : "test-namespace" ,
411
- "k8s.pod.name" : "test-pod-0" ,
409
+ "k8s.service.test-service" : "" ,
410
+ "k8s-app" : "my-app" ,
411
+ "k8s.pod.phase" : "Running" ,
412
+ "k8s.namespace.name" : "test-namespace" ,
413
+ "k8s.pod.name" : "test-pod-0" ,
414
+ conventions .AttributeK8SNodeName : "test-node" ,
412
415
}),
413
416
},
414
417
},
0 commit comments