diff --git a/instrumentor/instrumentation/instrumentation.go b/instrumentor/instrumentation/instrumentation.go index d7a9d598c..1944c16f7 100644 --- a/instrumentor/instrumentation/instrumentation.go +++ b/instrumentor/instrumentation/instrumentation.go @@ -43,8 +43,8 @@ func ApplyInstrumentationDevicesToPodTemplate(original *corev1.PodTemplateSpec, containerHaveOtherAgent := getContainerOtherAgents(runtimeDetails, container.Name) // In case there is another agent in the container, we should not apply the instrumentation device. - if containerLanguage == common.PythonProgrammingLanguage && containerHaveOtherAgent != nil { - logger.Info("Python container has other agent, skip applying instrumentation device", "agent", containerHaveOtherAgent.Name, "container", container.Name) + if containerHaveOtherAgent != nil { + logger.Info("Container is running other agent, skip applying instrumentation device", "agent", containerHaveOtherAgent.Name, "container", container.Name) // Not actually modifying the container, but we need to append it to the list. modifiedContainers = append(modifiedContainers, container) diff --git a/odiglet/pkg/kube/runtime_details/inspection.go b/odiglet/pkg/kube/runtime_details/inspection.go index 4cad643cf..d0772de50 100644 --- a/odiglet/pkg/kube/runtime_details/inspection.go +++ b/odiglet/pkg/kube/runtime_details/inspection.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "errors" + "strings" procdiscovery "github.com/odigos-io/odigos/procdiscovery/pkg/process" @@ -124,11 +125,18 @@ func runtimeInspection(pods []corev1.Pod, ignoredContainers []string) ([]odigosv envs = append(envs, odigosv1.EnvVar{Name: envName, Value: envValue}) } + // Languages that can be detected using environment variables, e.g Python<>newrelic for envName := range inspectProc.Environments.DetailedEnvs { if otherAgentName, exists := procdiscovery.OtherAgentEnvs[envName]; exists { detectedAgent = &odigosv1.OtherAgent{Name: otherAgentName} } } + // Languages that can be detected using command line Substrings, e.g. Java<>newrelic + for otherAgentCmdSubstring, otherAgentName := range procdiscovery.OtherAgentCmdSubString { + if strings.Contains(inspectProc.CmdLine, otherAgentCmdSubstring) { + detectedAgent = &odigosv1.OtherAgent{Name: otherAgentName} + } + } } var runtimeVersion string diff --git a/procdiscovery/pkg/process/process.go b/procdiscovery/pkg/process/process.go index cbac14d6f..549bb03c8 100644 --- a/procdiscovery/pkg/process/process.go +++ b/procdiscovery/pkg/process/process.go @@ -27,6 +27,10 @@ var OtherAgentEnvs = map[string]string{ NewRelicAgentEnv: "New Relic Agent", } +var OtherAgentCmdSubString = map[string]string{ + "newrelic.jar": "New Relic Agent", +} + type Details struct { ProcessID int ExeName string