Skip to content

Commit

Permalink
Detect newrelic also in java (#1875)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirdavid1 authored Nov 28, 2024
1 parent 070a2f1 commit 921a378
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions instrumentor/instrumentation/instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions odiglet/pkg/kube/runtime_details/inspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"strings"

procdiscovery "github.com/odigos-io/odigos/procdiscovery/pkg/process"

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions procdiscovery/pkg/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 921a378

Please sign in to comment.