in otelcollector/prometheusreceiver/internal/prom_to_otlp.go [90:112]
func addKubernetesResource(attrs pcommon.Map, serviceDiscoveryLabels labels.Labels) {
for sdKey, attributeKey := range kubernetesDiscoveryToResourceAttributes {
if attr := serviceDiscoveryLabels.Get(sdKey); attr != "" {
attrs.PutStr(attributeKey, attr)
}
}
controllerName := serviceDiscoveryLabels.Get("__meta_kubernetes_pod_controller_name")
controllerKind := serviceDiscoveryLabels.Get("__meta_kubernetes_pod_controller_kind")
if controllerKind != "" && controllerName != "" {
switch controllerKind {
case "ReplicaSet":
attrs.PutStr(conventions.AttributeK8SReplicaSetName, controllerName)
case "DaemonSet":
attrs.PutStr(conventions.AttributeK8SDaemonSetName, controllerName)
case "StatefulSet":
attrs.PutStr(conventions.AttributeK8SStatefulSetName, controllerName)
case "Job":
attrs.PutStr(conventions.AttributeK8SJobName, controllerName)
case "CronJob":
attrs.PutStr(conventions.AttributeK8SCronJobName, controllerName)
}
}
}