Skip to content

Commit

Permalink
fix lint, update call site with old fn
Browse files Browse the repository at this point in the history
  • Loading branch information
stanistan committed Dec 4, 2024
1 parent 0d8f6b0 commit b5860a5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,26 @@ func profilingClientLibraryConfigMutators(config *webhookConfig) []podMutator {
return podMutators
}

func injectApmTelemetryConfig(pod *corev1.Pod) {
// inject DD_INSTRUMENTATION_INSTALL_TIME with current Unix time
instrumentationInstallTime := os.Getenv(instrumentationInstallTimeEnvVarName)
if instrumentationInstallTime == "" {
instrumentationInstallTime = common.ClusterAgentStartTime
}
instrumentationInstallTimeEnvVar := corev1.EnvVar{
Name: instrumentationInstallTimeEnvVarName,
Value: instrumentationInstallTime,
}
_ = mutatecommon.InjectEnv(pod, instrumentationInstallTimeEnvVar)

// inject DD_INSTRUMENTATION_INSTALL_ID with UUID created during the Agent install time
instrumentationInstallIDEnvVar := corev1.EnvVar{
Name: instrumentationInstallIDEnvVarName,
Value: os.Getenv(instrumentationInstallIDEnvVarName),
}
_ = mutatecommon.InjectEnv(pod, instrumentationInstallIDEnvVar)
}

type libInfoLanguageDetection struct {
libs []libInfo
injectionEnabled bool
Expand Down Expand Up @@ -343,23 +363,8 @@ func (s libInfoSource) mutatePod(pod *corev1.Pod) error {
Value: s.injectionType(),
})

// inject DD_INSTRUMENTATION_INSTALL_TIME with current Unix time
instrumentationInstallTime := os.Getenv(instrumentationInstallTimeEnvVarName)
if instrumentationInstallTime == "" {
instrumentationInstallTime = common.ClusterAgentStartTime
}
instrumentationInstallTimeEnvVar := corev1.EnvVar{
Name: instrumentationInstallTimeEnvVarName,
Value: instrumentationInstallTime,
}
_ = mutatecommon.InjectEnv(pod, instrumentationInstallTimeEnvVar)
injectApmTelemetryConfig(pod)

// inject DD_INSTRUMENTATION_INSTALL_ID with UUID created during the Agent install time
instrumentationInstallIDEnvVar := corev1.EnvVar{
Name: instrumentationInstallIDEnvVarName,
Value: os.Getenv(instrumentationInstallIDEnvVarName),
}
_ = mutatecommon.InjectEnv(pod, instrumentationInstallIDEnvVar)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2307,7 +2307,7 @@ func TestInjectAutoInstrumentation(t *testing.T) {
"admission.datadoghq.com/enabled": "false",
},
}.Create(),
expectedEnvs: nil,
expectedEnvs: nil,
expectedInjectedLibraries: map[string]string{},
expectedSecurityContext: &corev1.SecurityContext{},
wantErr: false,
Expand Down Expand Up @@ -2406,7 +2406,7 @@ func TestInjectAutoInstrumentation(t *testing.T) {
ParentKind: "replicaset",
ParentName: "test-deployment-123",
}.Create(),
expectedEnvs: nil,
expectedEnvs: nil,
expectedInjectedLibraries: map[string]string{},
expectedSecurityContext: &corev1.SecurityContext{},
wantErr: false,
Expand Down Expand Up @@ -2477,7 +2477,7 @@ func TestInjectAutoInstrumentation(t *testing.T) {
ParentKind: "replicaset",
ParentName: "test-deployment-123",
}.Create(),
expectedEnvs: nil,
expectedEnvs: nil,
expectedInjectedLibraries: map[string]string{},
expectedSecurityContext: &corev1.SecurityContext{},
wantErr: false,
Expand All @@ -2490,7 +2490,7 @@ func TestInjectAutoInstrumentation(t *testing.T) {
ParentKind: "replicaset",
ParentName: "test-deployment-123",
}.Create(),
expectedEnvs: nil,
expectedEnvs: nil,
expectedInjectedLibraries: map[string]string{},
expectedSecurityContext: &corev1.SecurityContext{},
wantErr: false,
Expand Down

0 comments on commit b5860a5

Please sign in to comment.