Skip to content

Commit 8420019

Browse files
committed
Remove the mapping of app.kubernetes.io/instance to service.instance.id, because multiple containers
should never share the same `service.instance.id`
1 parent bca76c6 commit 8420019

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/instrumentation/sdk.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ func chooseServiceVersion(pod corev1.Pod, useLabelsForResourceAttributes bool, i
472472
// 1. annotation with key "service.instance.id"
473473
// 2. namespace name + pod name + container name
474474
// (as defined by https://opentelemetry.io/docs/specs/semconv/resource/#service-experimental)
475-
func createServiceInstanceId(pod corev1.Pod, useLabelsForResourceAttributes bool, namespaceName, podName, containerName string) string {
475+
func createServiceInstanceId(pod corev1.Pod, namespaceName, podName, containerName string) string {
476476
// Do not use labels for service instance id,
477477
// because multiple containers in the same pod would get the same service instance id,
478478
// which violates the uniqueness requirement of service instance id -
@@ -527,7 +527,7 @@ func (i *sdkInjector) createResourceMap(ctx context.Context, otelinst v1alpha1.I
527527
k8sResources[semconv.K8SPodNameKey] = pod.Name
528528
k8sResources[semconv.K8SPodUIDKey] = string(pod.UID)
529529
k8sResources[semconv.K8SNodeNameKey] = pod.Spec.NodeName
530-
k8sResources[semconv.ServiceInstanceIDKey] = createServiceInstanceId(pod, useLabelsForResourceAttributes, ns.Name, fmt.Sprintf("$(%s)", constants.EnvPodName), pod.Spec.Containers[index].Name)
530+
k8sResources[semconv.ServiceInstanceIDKey] = createServiceInstanceId(pod, ns.Name, fmt.Sprintf("$(%s)", constants.EnvPodName), pod.Spec.Containers[index].Name)
531531
i.addParentResourceLabels(ctx, otelinst.Spec.Resource.AddK8sUIDAttributes, ns, pod.ObjectMeta, k8sResources)
532532

533533
for k, v := range k8sResources {

0 commit comments

Comments
 (0)