Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect newrelic also in java #1875

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading