Repository: DataDog/helm-charts
Pull request #1766: [CECO-2073] Align core Agent config with processes-specific config
Author: login: tbavelier
Labels: name: chart/datadog
description: This issue or pull request is related to the datadog chart
name: mergequeue-status: done
Created: 2025-03-21T13:06:55Z | Merged: 2025-03-27T09:11:16Z

#### What this PR does / why we need it:

* Ensures any specific processes (trace agent, process agent) config (e.g. APM enabled) is also present on the core Agent
    * `system-probe` configuration is done via a ConfigMap already mounted on the core Agent through `/etc/datadog-agent/system-probe.yaml`
    * security-agent configuration will be done in a subsequent PR / is lower priority since today, the core Agent queries the security Agent config (`security-agent.yaml`) so the information is already accurate

#### Motivation

* Ensures the core Agent metadata payload properly reflects configuration

#### Special notes for your reviewer:

#### Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]
- [ ] Chart Version bumped
- [ ] Documentation has been updated with helm-docs (run: `.github/helm-docs.sh`)
- [ ] `CHANGELOG.md` has been updated
- [ ] Variables are documented in the `README.md`
- [ ] For `datadog` or `datadog-operator` chart or value changes, update the test baselines (run: `make update-test-baselines`)



Diff:
diff --git a/charts/datadog/CHANGELOG.md b/charts/datadog/CHANGELOG.md
index 3d1ec3d2b6..8c9b5822d9 100644
--- a/charts/datadog/CHANGELOG.md
+++ b/charts/datadog/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Datadog changelog
 
+## 3.110.4
+
+* Propagate trace/process-Agents specific configuration parameters to the core Agent to accurately reflect the metadata payload.
+
 ## 3.110.3
 
 * Update `datadog-crds` dependency to `2.5.1` and auto-activate datadogpodautoscalers collection in orchestrator.
diff --git a/charts/datadog/Chart.yaml b/charts/datadog/Chart.yaml
index b39c80a196..086f67b5f9 100644
--- a/charts/datadog/Chart.yaml
+++ b/charts/datadog/Chart.yaml
@@ -1,7 +1,7 @@
 ---
 apiVersion: v1
 name: datadog
-version: 3.110.3
+version: 3.110.4
 appVersion: "7"
 description: Datadog Agent
 keywords:
diff --git a/charts/datadog/README.md b/charts/datadog/README.md
index 2dc91b2359..aefa46e139 100644
--- a/charts/datadog/README.md
+++ b/charts/datadog/README.md
@@ -1,6 +1,6 @@
 # Datadog
 
-![Version: 3.110.3](https://img.shields.io/badge/Version-3.110.3-informational?style=flat-square) ![AppVersion: 7](https://img.shields.io/badge/AppVersion-7-informational?style=flat-square)
+![Version: 3.110.4](https://img.shields.io/badge/Version-3.110.4-informational?style=flat-square) ![AppVersion: 7](https://img.shields.io/badge/AppVersion-7-informational?style=flat-square)
 
 [Datadog](https://www.datadoghq.com/) is a hosted infrastructure monitoring platform. This chart adds the Datadog Agent to all nodes in your cluster via a DaemonSet. It also optionally depends on the [kube-state-metrics chart](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics). For more information about monitoring Kubernetes with Datadog, please refer to the [Datadog documentation website](https://docs.datadoghq.com/agent/basic_agent_usage/kubernetes/).
 
diff --git a/charts/datadog/templates/_container-agent.yaml b/charts/datadog/templates/_container-agent.yaml
index ed1630a55a..47846b1a5f 100644
--- a/charts/datadog/templates/_container-agent.yaml
+++ b/charts/datadog/templates/_container-agent.yaml
@@ -120,6 +120,31 @@
     {{- end }}
     - name: DD_APM_ENABLED
       value: {{ include "should-enable-trace-agent" . | quote }}
+    {{- if eq (include "should-enable-trace-agent" .) "true" }}
+    - name: DD_APM_NON_LOCAL_TRAFFIC
+      value: "true"
+    - name: DD_APM_RECEIVER_PORT
+      value: {{ .Values.datadog.apm.port | quote }}
+    {{- if eq (include "trace-agent-use-uds" .) "true" }}
+    - name: DD_APM_RECEIVER_SOCKET
+      value: {{ .Values.datadog.apm.socketPath | quote }}
+    {{- end }}
+    - name: DD_INSTRUMENTATION_INSTALL_TIME
+      valueFrom:
+        configMapKeyRef:
+          name: {{ template "datadog.fullname" . }}-kpi-telemetry-configmap
+          key: install_time
+    - name: DD_INSTRUMENTATION_INSTALL_ID
+      valueFrom:
+        configMapKeyRef:
+          name: {{ template "datadog.fullname" . }}-kpi-telemetry-configmap
+          key: install_id
+    - name: DD_INSTRUMENTATION_INSTALL_TYPE
+      valueFrom:
+        configMapKeyRef:
+          name: {{ template "datadog.fullname" . }}-kpi-telemetry-configmap
+          key: install_type
+    {{- end }}
     - name: DD_LOGS_ENABLED
       value: {{  (default false (or .Values.datadog.logs.enabled .Values.datadog.logsEnabled)) | quote}}
     - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
@@ -222,6 +247,14 @@
     - name: NVIDIA_VISIBLE_DEVICES
       value: all
     {{- end }}
+    {{- if eq  (include "should-enable-process-agent" .) "true" }}
+    - name: DD_SYSTEM_PROBE_ENABLED
+      value: {{ .Values.datadog.networkMonitoring.enabled | quote }}
+    {{- if .Values.datadog.networkMonitoring.enabled }}
+    - name: DD_SYSTEM_PROBE_NETWORK_ENABLED
+      value: {{ .Values.datadog.networkMonitoring.enabled | quote }}
+    {{- end }}
+    {{- end }}
     {{- include "additional-env-entries" .Values.agents.containers.agent.env | indent 4 }}
     {{- include "additional-env-dict-entries" .Values.agents.containers.agent.envDict | indent 4 }}
   volumeMounts:
diff --git a/test/datadog/baseline/manifests/agent-clusterchecks-deployment_default.yaml b/test/datadog/baseline/manifests/agent-clusterchecks-deployment_default.yaml
index 62ca3df974..9306112b1f 100644
--- a/test/datadog/baseline/manifests/agent-clusterchecks-deployment_default.yaml
+++ b/test/datadog/baseline/manifests/agent-clusterchecks-deployment_default.yaml
@@ -823,6 +823,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
diff --git a/test/datadog/baseline/manifests/daemonset_default.yaml b/test/datadog/baseline/manifests/daemonset_default.yaml
index df26b1a633..5180a8baa8 100644
--- a/test/datadog/baseline/manifests/daemonset_default.yaml
+++ b/test/datadog/baseline/manifests/daemonset_default.yaml
@@ -788,6 +788,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
diff --git a/test/datadog/baseline/manifests/default_all.yaml b/test/datadog/baseline/manifests/default_all.yaml
index df26b1a633..5180a8baa8 100644
--- a/test/datadog/baseline/manifests/default_all.yaml
+++ b/test/datadog/baseline/manifests/default_all.yaml
@@ -788,6 +788,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
diff --git a/test/datadog/baseline/manifests/default_all_windows.yaml b/test/datadog/baseline/manifests/default_all_windows.yaml
index 6daa51f093..553dce6f2b 100644
--- a/test/datadog/baseline/manifests/default_all_windows.yaml
+++ b/test/datadog/baseline/manifests/default_all_windows.yaml
@@ -814,6 +814,8 @@ spec:
               value: "true"
             - name: DD_KUBERNETES_KUBELET_PODRESOURCES_SOCKET
               value: /var/lib/kubelet/pod-resources/kubelet.sock
+            - name: DD_SYSTEM_PROBE_ENABLED
+              value: "false"
           image: gcr.io/datadoghq/agent:7.64.1
           imagePullPolicy: IfNotPresent
           livenessProbe:
diff --git a/test/datadog/baseline/manifests/gke_autopilot_daemonset_default.yaml b/test/datadog/baseline/manifests/gke_autopilot_daemonset_default.yaml
index 42ab8cda77..e8adf924ad 100644
--- a/test/datadog/baseline/manifests/gke_autopilot_daemonset_default.yaml
+++ b/test/datadog/baseline/manifests/gke_autopilot_daemonset_default.yaml
@@ -820,6 +820,8 @@ spec:
               value: "true"
             - name: DD_KUBELET_CORE_CHECK_ENABLED
               value: "true"
+            - name: DD_SYSTEM_PROBE_ENABLED
+              value: "false"
           image: gcr.io/datadoghq/agent:7.64.1
           imagePullPolicy: IfNotPresent
           livenessProbe:
diff --git a/test/datadog/baseline/manifests/npm_daemonset_default.yaml b/test/datadog/baseline/manifests/npm_daemonset_default.yaml
index db36d082af..10a88ec662 100644
--- a/test/datadog/baseline/manifests/npm_daemonset_default.yaml
+++ b/test/datadog/baseline/manifests/npm_daemonset_default.yaml
@@ -1034,6 +1034,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
@@ -1064,6 +1085,10 @@ spec:
               value: "true"
             - name: DD_KUBERNETES_KUBELET_PODRESOURCES_SOCKET
               value: /var/lib/kubelet/pod-resources/kubelet.sock
+            - name: DD_SYSTEM_PROBE_ENABLED
+              value: "true"
+            - name: DD_SYSTEM_PROBE_NETWORK_ENABLED
+              value: "true"
           image: gcr.io/datadoghq/agent:7.64.1
           imagePullPolicy: IfNotPresent
           livenessProbe:
diff --git a/test/datadog/baseline/manifests/otel-agent_logs_collection.yaml b/test/datadog/baseline/manifests/otel-agent_logs_collection.yaml
index 7203cff1ce..c5b13e5dc0 100644
--- a/test/datadog/baseline/manifests/otel-agent_logs_collection.yaml
+++ b/test/datadog/baseline/manifests/otel-agent_logs_collection.yaml
@@ -823,6 +823,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
diff --git a/test/datadog/baseline/manifests/otel-agent_volume_mounts.yaml b/test/datadog/baseline/manifests/otel-agent_volume_mounts.yaml
index 4c86442f6c..ade0ecdc53 100644
--- a/test/datadog/baseline/manifests/otel-agent_volume_mounts.yaml
+++ b/test/datadog/baseline/manifests/otel-agent_volume_mounts.yaml
@@ -860,6 +860,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
diff --git a/test/datadog/baseline/manifests/otel_enabled.yaml b/test/datadog/baseline/manifests/otel_enabled.yaml
index 3f4463f9d7..a63f77cf66 100644
--- a/test/datadog/baseline/manifests/otel_enabled.yaml
+++ b/test/datadog/baseline/manifests/otel_enabled.yaml
@@ -860,6 +860,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
diff --git a/test/datadog/baseline/manifests/other_default.yaml b/test/datadog/baseline/manifests/other_default.yaml
index df26b1a633..5180a8baa8 100644
--- a/test/datadog/baseline/manifests/other_default.yaml
+++ b/test/datadog/baseline/manifests/other_default.yaml
@@ -788,6 +788,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
diff --git a/test/datadog/baseline/manifests/system_probe_daemonset_default.yaml b/test/datadog/baseline/manifests/system_probe_daemonset_default.yaml
index dd7dc24591..43dc9edfe0 100644
--- a/test/datadog/baseline/manifests/system_probe_daemonset_default.yaml
+++ b/test/datadog/baseline/manifests/system_probe_daemonset_default.yaml
@@ -1034,6 +1034,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
@@ -1064,6 +1085,10 @@ spec:
               value: "true"
             - name: DD_KUBERNETES_KUBELET_PODRESOURCES_SOCKET
               value: /var/lib/kubelet/pod-resources/kubelet.sock
+            - name: DD_SYSTEM_PROBE_ENABLED
+              value: "true"
+            - name: DD_SYSTEM_PROBE_NETWORK_ENABLED
+              value: "true"
           image: gcr.io/datadoghq/agent:7.64.1
           imagePullPolicy: IfNotPresent
           livenessProbe:
diff --git a/test/datadog/baseline/manifests/usm_daemonset_default.yaml b/test/datadog/baseline/manifests/usm_daemonset_default.yaml
index 9dce603f20..72891d3e93 100644
--- a/test/datadog/baseline/manifests/usm_daemonset_default.yaml
+++ b/test/datadog/baseline/manifests/usm_daemonset_default.yaml
@@ -1034,6 +1034,27 @@ spec:
                   name: datadog-cluster-agent
             - name: DD_APM_ENABLED
               value: "true"
+            - name: DD_APM_NON_LOCAL_TRAFFIC
+              value: "true"
+            - name: DD_APM_RECEIVER_PORT
+              value: "8126"
+            - name: DD_APM_RECEIVER_SOCKET
+              value: /var/run/datadog/apm.socket
+            - name: DD_INSTRUMENTATION_INSTALL_TIME
+              valueFrom:
+                configMapKeyRef:
+                  key: install_time
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_ID
+              valueFrom:
+                configMapKeyRef:
+                  key: install_id
+                  name: datadog-kpi-telemetry-configmap
+            - name: DD_INSTRUMENTATION_INSTALL_TYPE
+              valueFrom:
+                configMapKeyRef:
+                  key: install_type
+                  name: datadog-kpi-telemetry-configmap
             - name: DD_LOGS_ENABLED
               value: "false"
             - name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
@@ -1064,6 +1085,10 @@ spec:
               value: "true"
             - name: DD_KUBERNETES_KUBELET_PODRESOURCES_SOCKET
               value: /var/lib/kubelet/pod-resources/kubelet.sock
+            - name: DD_SYSTEM_PROBE_ENABLED
+              value: "true"
+            - name: DD_SYSTEM_PROBE_NETWORK_ENABLED
+              value: "true"
           image: gcr.io/datadoghq/agent:7.64.1
           imagePullPolicy: IfNotPresent
           livenessProbe:
diff --git a/test/datadog/unified_core_agent_config_test.go b/test/datadog/unified_core_agent_config_test.go
new file mode 100644
index 0000000000..d37e29aaef
--- /dev/null
+++ b/test/datadog/unified_core_agent_config_test.go
@@ -0,0 +1,108 @@
+package datadog
+
+import (
+	"fmt"
+	"strings"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	appsv1 "k8s.io/api/apps/v1"
+
+	"github.com/DataDog/helm-charts/test/common"
+)
+
+// Test_UnifiedCoreAgentConfig tests that all DD-prefixed environment variables from process-agent and trace-agent
+// are also set in the core agent with the same values.
+// This is to ensure that the process-specific (process-agent and trace-agent) configurations are correctly propagated to the core agent for metadata payload.
+func Test_UnifiedCoreAgentConfig(t *testing.T) {
+	tests := []struct {
+		name       string
+		command    common.HelmCommand
+		assertFunc func(t *testing.T, manifest string)
+	}{
+		{
+			name: "DD-prefixed env vars in core agent",
+			command: common.HelmCommand{
+				ReleaseName: "datadog",
+				ChartPath:   "../../charts/datadog",
+				ShowOnly:    []string{"templates/daemonset.yaml"},
+				Values:      []string{"../../charts/datadog/values.yaml"},
+				Overrides: map[string]string{
+					"datadog.apiKeyExistingSecret":      "datadog-secret",
+					"datadog.appKeyExistingSecret":      "datadog-secret",
+					"datadog.networkMonitoring.enabled": "true", // Required to enable process-agent
+				},
+			},
+			assertFunc: verifyEnvVarsSync,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			manifest, err := common.RenderChart(t, tt.command)
+			assert.Nil(t, err, "couldn't render template")
+			tt.assertFunc(t, manifest)
+		})
+	}
+}
+
+// verifyEnvVarsSync checks that all DD-prefixed environment variables from process-agent and trace-agent
+// are also set in the core agent with the same values.
+func verifyEnvVarsSync(t *testing.T, manifest string) {
+	var daemonset appsv1.DaemonSet
+	common.Unmarshal(t, manifest, &daemonset)
+
+	// Get containers
+	coreAgentContainer, coreAgentFound := getContainer(t, daemonset.Spec.Template.Spec.Containers, "agent")
+	assert.True(t, coreAgentFound, "Core agent container not found")
+
+	processAgentContainer, processAgentFound := getContainer(t, daemonset.Spec.Template.Spec.Containers, "process-agent")
+	assert.True(t, processAgentFound, "Process agent container not found")
+
+	traceAgentContainer, traceAgentFound := getContainer(t, daemonset.Spec.Template.Spec.Containers, "trace-agent")
+	assert.True(t, traceAgentFound, "Trace agent container not found")
+
+	// Get environment variable maps
+	coreAgentEnvMap := getEnvVarMap(coreAgentContainer.Env)
+	processAgentEnvMap := getEnvVarMap(processAgentContainer.Env)
+	traceAgentEnvMap := getEnvVarMap(traceAgentContainer.Env)
+
+	// Check that all DD-prefixed env vars from process agent are in core agent with the same value
+	var missingOrDifferentVars []string
+
+	for envName, envValue := range processAgentEnvMap {
+		if strings.HasPrefix(envName, "DD_") {
+
+			coreValue, exists := coreAgentEnvMap[envName]
+			if !exists {
+				missingOrDifferentVars = append(missingOrDifferentVars,
+					fmt.Sprintf("%s (missing from core-agent)", envName))
+			} else if coreValue != envValue {
+				missingOrDifferentVars = append(missingOrDifferentVars,
+					fmt.Sprintf("%s (value differs: process-agent=%q, core-agent=%q)",
+						envName, envValue, coreValue))
+			}
+		}
+	}
+
+	// Check that all DD-prefixed env vars from trace agent are in core agent with the same value
+	for envName, envValue := range traceAgentEnvMap {
+		if strings.HasPrefix(envName, "DD_") {
+
+			coreValue, exists := coreAgentEnvMap[envName]
+			if !exists {
+				missingOrDifferentVars = append(missingOrDifferentVars,
+					fmt.Sprintf("%s (missing from core-agent)", envName))
+			} else if coreValue != envValue {
+				missingOrDifferentVars = append(missingOrDifferentVars,
+					fmt.Sprintf("%s (value differs: trace-agent=%q, core-agent=%q)",
+						envName, envValue, coreValue))
+			}
+		}
+	}
+
+	// Assert that all required variables are synced correctly
+	assert.Empty(t, missingOrDifferentVars,
+		"Found missing or different DD-prefixed environment variables in core agent: %v",
+		missingOrDifferentVars)
+}


Reviews:
user: login: tbavelier
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-24T13:33:40Z
user: login: hmahmood
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-24T16:49:16Z
user: login: tbavelier
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-25T08:36:47Z
user: login: hmahmood
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-25T14:49:25Z
user: login: khewonc
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-26T15:57:53Z

Review comments:
diff_hunk: @@ -120,6 +120,31 @@
     {{- end }}
     - name: DD_APM_ENABLED
       value: {{ include "should-enable-trace-agent" . | quote }}
+    {{- if eq (include "should-enable-trace-agent" .) "true" }}
path: charts/datadog/templates/_container-agent.yaml
user: login: tbavelier
body: We need to keep `DD_APM_ENABLED` outside this big `"should-enable-trace-agent"` block since on Windows, we want to keep `DD_APM_ENABLED=false` by default (unless user enables TCP, which is disabled by default)
created_at: 2025-03-24T13:30:38Z
author_association: MEMBER
diff_hunk: @@ -222,6 +247,14 @@
     - name: NVIDIA_VISIBLE_DEVICES
       value: all
     {{- end }}
+    {{- if eq  (include "should-enable-process-agent" .) "true" }}
path: charts/datadog/templates/_container-agent.yaml
user: login: hmahmood
body: There is also a `should-enable-system-probe` macro; any reason not to use that here?
created_at: 2025-03-24T16:49:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -222,6 +247,14 @@
     - name: NVIDIA_VISIBLE_DEVICES
       value: all
     {{- end }}
+    {{- if eq  (include "should-enable-process-agent" .) "true" }}
path: charts/datadog/templates/_container-agent.yaml
user: login: tbavelier
body: yes, the intent is to make sure the core Agent gets the same config as the other processes. These 2 env vars are solely defined in the process Agent whether or not system-probe is enabled: https://github.com/DataDog/helm-charts/blob/d1a485fb11eb8df1faa3115489ee3ac8831683e7/charts/datadog/templates/_container-process-agent.yaml#L38-L42, so gating them behind should-enable-system-probe could lead to a discrepancy between what's on the process Agent vs what's on the core Agent
created_at: 2025-03-25T08:36:47Z
author_association: MEMBER

PR comments:
user: login: tbavelier
created_at: 2025-03-27T08:34:26Z
body: /merge
author_association: MEMBER
user: login: dd-devflow[bot]
created_at: 2025-03-27T08:34:30Z
body: <!-- "FeedbackWorkflowId":"d6c43807-e98d-494e-addd-ecfff3d8adae_36" -->
[View all feedbacks in Devflow UI.](https://devflow.static-app.us1.prod.dog/logs/d6c43807-e98d-494e-addd-ecfff3d8adae_36)
`2025-03-27 08:34:30 UTC` :information_source: Start processing command `/merge`

---
`2025-03-27 08:34:35 UTC` :information_source: **MergeQueue:** pull request added to the queue

The expected merge time in `main` is approximately 42m (p90).

---
`2025-03-27 09:11:20 UTC` :information_source: **MergeQueue:** This merge request was merged

author_association: NONE