⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
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
32 changes: 22 additions & 10 deletions src/java/frameworks/azure_application_insights_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,12 @@ func (a *AzureApplicationInsightsAgentFramework) Supply() error {
a.context.Log.Warning("Could not install default Azure Application Insights configuration: %s", err.Error())
}

// Find the installed JAR
jarPattern := filepath.Join(agentDir, "applicationinsights-agent-*.jar")
matches, err := filepath.Glob(jarPattern)
// constructJarPath can be skipped here and do it only in finalize, but it can be left as a double check
// if jar path exists after the dependency install
err = a.constructJarPath(agentDir)
if err != nil {
return fmt.Errorf("failed to search for Azure Application Insights agent JAR: %w", err)
}
if len(matches) == 0 {
return fmt.Errorf("Azure Application Insights agent JAR not found after installation in %s", agentDir)
return fmt.Errorf("azure application insights agent not found during supply: %w", err)
}
a.jarPath = matches[0]

a.context.Log.Info("Azure Application Insights agent %s installed", dep.Version)
return nil
Expand Down Expand Up @@ -145,8 +141,10 @@ func (a *AzureApplicationInsightsAgentFramework) installDefaultConfiguration(age

// Finalize configures the Azure Application Insights agent
func (a *AzureApplicationInsightsAgentFramework) Finalize() error {
if a.jarPath == "" {
return nil
agentDir := filepath.Join(a.context.Stager.DepDir(), "azure_application_insights_agent")
err := a.constructJarPath(agentDir)
if err != nil {
return fmt.Errorf("azure application insights agent not found during finalize: %w", err)
}

a.context.Log.BeginStep("Configuring Azure Application Insights agent")
Expand Down Expand Up @@ -277,3 +275,17 @@ func (a *AzureApplicationInsightsAgentFramework) getApplicationName() string {

return ""
}

func (a *AzureApplicationInsightsAgentFramework) constructJarPath(agentDir string) error {
// Find the installed JAR
jarPattern := filepath.Join(agentDir, "applicationinsights-agent-*.jar")
matches, err := filepath.Glob(jarPattern)
if err != nil {
return fmt.Errorf("failed to search for Azure Application Insights agent JAR: %w", err)
}
if len(matches) == 0 {
return fmt.Errorf("agent jar not found after installation in %s", agentDir)
}
a.jarPath = matches[0]
return nil
}
5 changes: 2 additions & 3 deletions src/java/frameworks/checkmarx_iast_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ func (c *CheckmarxIASTAgentFramework) Supply() error {

// Finalize configures the Checkmarx IAST agent
func (c *CheckmarxIASTAgentFramework) Finalize() error {
if c.jarPath == "" {
return nil
}
agentDir := filepath.Join(c.context.Stager.DepDir(), "checkmarx_iast_agent")
c.jarPath = filepath.Join(agentDir, "cx-agent.jar")

c.context.Log.BeginStep("Configuring Checkmarx IAST agent")

Expand Down
44 changes: 28 additions & 16 deletions src/java/frameworks/datadog_javaagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,11 @@ func (d *DatadogJavaagentFramework) Supply() error {
return fmt.Errorf("failed to install Datadog Javaagent: %w", err)
}

// Find the installed JAR
jarPattern := filepath.Join(datadogDir, "dd-java-agent*.jar")
matches, err := filepath.Glob(jarPattern)
// constructJarPathAndFixClassCount can be skipped here and do it only in finalize, but it can be left
// as a double check if jar path exists after the dependency install
err = d.constructJarPathAndFixClassCount(datadogDir)
if err != nil {
return fmt.Errorf("failed to search for Datadog agent JAR: %w", err)
}
if len(matches) == 0 {
return fmt.Errorf("Datadog agent JAR not found after installation in %s", datadogDir)
}
d.jarPath = matches[0]

// Fix class count (critical for Datadog agent)
if err := d.fixClassCount(); err != nil {
d.context.Log.Warning("Failed to fix class count: %s", err)
// Continue anyway
return fmt.Errorf("datadog Java agent JAR path not found during supply: %w", err)
}

d.context.Log.Info("Datadog Java agent %s installed", dep.Version)
Expand All @@ -119,8 +109,10 @@ func (d *DatadogJavaagentFramework) Supply() error {

// Finalize configures the Datadog Java agent
func (d *DatadogJavaagentFramework) Finalize() error {
if d.jarPath == "" {
return nil
datadogDir := filepath.Join(d.context.Stager.DepDir(), "datadog_javaagent")
err := d.constructJarPathAndFixClassCount(datadogDir)
if err != nil {
return fmt.Errorf("datadog Java agent JAR path not found during finalize: %w", err)
}

d.context.Log.BeginStep("Configuring Datadog Java agent")
Expand Down Expand Up @@ -310,3 +302,23 @@ func (d *DatadogJavaagentFramework) getApplicationVersion() string {

return ""
}

func (d *DatadogJavaagentFramework) constructJarPathAndFixClassCount(datadogDir string) error {
// Find the installed JAR
jarPattern := filepath.Join(datadogDir, "dd-java-agent*.jar")
matches, err := filepath.Glob(jarPattern)
if err != nil {
return fmt.Errorf("failed to search for Datadog agent JAR: %w", err)
}
if len(matches) == 0 {
return fmt.Errorf("agent jar not found after installation in %s", datadogDir)
}
d.jarPath = matches[0]

// Fix class count (critical for Datadog agent)
if err := d.fixClassCount(); err != nil {
d.context.Log.Warning("Failed to fix class count: %s", err)
// Continue anyway
}
return nil
}
36 changes: 26 additions & 10 deletions src/java/frameworks/elastic_apm_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,28 @@ func (e *ElasticApmAgentFramework) Supply() error {
return fmt.Errorf("failed to install Elastic APM agent: %w", err)
}

// Find the installed JAR
jarPattern := filepath.Join(elasticDir, "elastic-apm-agent*.jar")
matches, err := filepath.Glob(jarPattern)
err = e.constructJarPath(elasticDir)
if err != nil {
return fmt.Errorf("failed to search for Elastic APM agent JAR: %w", err)
return fmt.Errorf("elastic apm agent jar not found during supply: %w", err)
}
if len(matches) == 0 {
return fmt.Errorf("Elastic APM agent JAR not found after installation in %s", elasticDir)
}
e.jarPath = matches[0]

e.context.Log.Info("Elastic APM agent %s installed", dep.Version)
return nil
}

// Finalize configures the Elastic APM agent
func (e *ElasticApmAgentFramework) Finalize() error {
if e.jarPath == "" || e.service == nil {
return nil
elasticDir := filepath.Join(e.context.Stager.DepDir(), "elastic_apm_agent")
err := e.constructJarPath(elasticDir)
if err != nil {
return fmt.Errorf("elastic apm agent jar not found during finalize: %w", err)
}
service := e.findElasticApmService()
// service should not be nil as detect has already passed
if service == nil {
e.context.Log.Debug("Elastic APM Agent: No elastic-apm service found")
}
e.service = service

e.context.Log.BeginStep("Configuring Elastic APM agent")

Expand Down Expand Up @@ -257,3 +259,17 @@ func (e *ElasticApmAgentFramework) getApplicationName() string {

return ""
}

func (e *ElasticApmAgentFramework) constructJarPath(elasticDir string) error {
// Find the installed JAR
jarPattern := filepath.Join(elasticDir, "elastic-apm-agent*.jar")
matches, err := filepath.Glob(jarPattern)
if err != nil {
return fmt.Errorf("failed to search for Elastic APM agent JAR: %w", err)
}
if len(matches) == 0 {
return fmt.Errorf("agent jar not found after installation in %s", elasticDir)
}
e.jarPath = matches[0]
return nil
}
26 changes: 19 additions & 7 deletions src/java/frameworks/google_stackdriver_profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,23 @@ func (g *GoogleStackdriverProfilerFramework) Supply() error {
return fmt.Errorf("failed to install Google Stackdriver Profiler: %w", err)
}

// Find the installed agent (native library)
agentPattern := filepath.Join(profilerDir, "profiler_java_agent.so")
if _, err := os.Stat(agentPattern); err != nil {
return fmt.Errorf("Google Stackdriver Profiler agent not found after installation: %w", err)
// constructAgentPath can be skipped here and do it only in finalize, but it can be left as a double check
// if jar path exists after the dependency install
err = g.constructAgentPath(profilerDir)
if err != nil {
return fmt.Errorf("google stackdriver profiler agent not found during supply: %w", err)
}
g.agentPath = agentPattern

g.context.Log.Info("Google Stackdriver Profiler %s installed", dep.Version)
return nil
}

// Finalize configures the Google Stackdriver Profiler
func (g *GoogleStackdriverProfilerFramework) Finalize() error {
if g.agentPath == "" {
return nil
profilerDir := filepath.Join(g.context.Stager.DepDir(), "google_stackdriver_profiler")
err := g.constructAgentPath(profilerDir)
if err != nil {
return fmt.Errorf("google stackdriver profiler agent not found during finalize: %w", err)
}

g.context.Log.BeginStep("Configuring Google Stackdriver Profiler")
Expand Down Expand Up @@ -233,3 +235,13 @@ func (g *GoogleStackdriverProfilerFramework) getApplicationVersion() string {

return ""
}

func (g *GoogleStackdriverProfilerFramework) constructAgentPath(profilerDir string) error {
// Find the installed agent (native library)
agentPattern := filepath.Join(profilerDir, "profiler_java_agent.so")
if _, err := os.Stat(agentPattern); err != nil {
return fmt.Errorf("agent not found after installation: %w", err)
}
g.agentPath = agentPattern
return nil
}
26 changes: 19 additions & 7 deletions src/java/frameworks/introscope_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,23 @@ func (i *IntroscopeAgentFramework) Supply() error {
return fmt.Errorf("failed to install Introscope agent: %w", err)
}

// Find the installed agent JAR
agentPattern := filepath.Join(agentDir, "Agent.jar")
if _, err := os.Stat(agentPattern); err != nil {
return fmt.Errorf("Introscope Agent.jar not found after installation: %w", err)
// constructAgentPath can be skipped here and do it only in finalize, but it can be left as a double check
// if jar path exists after the dependency install
err = i.constructAgentPath(agentDir)
if err != nil {
return fmt.Errorf("introscope Agent.jar not found during supply: %w", err)
}
i.agentPath = agentPattern

i.context.Log.Info("Introscope agent %s installed", dep.Version)
return nil
}

// Finalize configures the Introscope agent
func (i *IntroscopeAgentFramework) Finalize() error {
if i.agentPath == "" {
return nil
agentDir := filepath.Join(i.context.Stager.DepDir(), "introscope_agent")
err := i.constructAgentPath(agentDir)
if err != nil {
return fmt.Errorf("introscope Agent.jar not found during finalize: %w", err)
}

i.context.Log.BeginStep("Configuring Introscope agent")
Expand Down Expand Up @@ -241,3 +243,13 @@ func (i *IntroscopeAgentFramework) getApplicationName() string {

return ""
}

func (i *IntroscopeAgentFramework) constructAgentPath(agentDir string) error {
// Find the installed agent JAR
agentPattern := filepath.Join(agentDir, "Agent.jar")
if _, err := os.Stat(agentPattern); err != nil {
return fmt.Errorf("agent jar not found after installation: %w", err)
}
i.agentPath = agentPattern
return nil
}
32 changes: 21 additions & 11 deletions src/java/frameworks/maria_db_jdbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,23 @@ func (f *MariaDBJDBCFramework) Supply() error {
return fmt.Errorf("failed to install MariaDB JDBC: %w", err)
}

// Find the installed JAR
jarPattern := filepath.Join(mariadbDir, "mariadb-jdbc-*.jar")
matches, err := filepath.Glob(jarPattern)
// constructJarPath can be skipped here and do it only in finalize, but it can be left as a double check
// if jar path exists after the dependency install
err = f.constructJarPath(mariadbDir)
if err != nil {
return fmt.Errorf("failed to search for MariaDB JDBC JAR: %w", err)
}
if len(matches) == 0 {
return fmt.Errorf("MariaDB JDBC JAR not found after installation in %s", mariadbDir)
return fmt.Errorf("jdbc jar not found during supply: %w", err)
}
f.jarPath = matches[0]

f.context.Log.Info("MariaDB JDBC %s installed", dep.Version)
return nil
}

// Finalize adds the MariaDB JDBC driver to the classpath
func (f *MariaDBJDBCFramework) Finalize() error {
if f.jarPath == "" {
// Not installed, skip
return nil
mariadbDir := filepath.Join(f.context.Stager.DepDir(), "mariadb_jdbc")
err := f.constructJarPath(mariadbDir)
if err != nil {
return fmt.Errorf("jdbc jar not found during finalize: %w", err)
}

f.context.Log.BeginStep("Configuring MariaDB JDBC driver")
Expand Down Expand Up @@ -192,3 +189,16 @@ func (f *MariaDBJDBCFramework) hasExistingDriver() bool {

return false
}

func (f *MariaDBJDBCFramework) constructJarPath(mariadbDir string) error {
jarPattern := filepath.Join(mariadbDir, "mariadb-jdbc-*.jar")
matches, err := filepath.Glob(jarPattern)
if err != nil {
return fmt.Errorf("failed to search for MariaDB JDBC JAR: %w", err)
}
if len(matches) == 0 {
return fmt.Errorf("jdbc jar not found after installation in %s", mariadbDir)
}
f.jarPath = matches[0]
return nil
}
26 changes: 19 additions & 7 deletions src/java/frameworks/riverbed_appinternals_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,23 @@ func (r *RiverbedAppInternalsAgentFramework) Supply() error {
return fmt.Errorf("failed to install Riverbed AppInternals agent: %w", err)
}

// Find the installed agent directory (contains lib/rvbd-agent.jar)
agentJarPath := filepath.Join(agentDir, "lib", "rvbd-agent.jar")
if _, err := os.Stat(agentJarPath); err != nil {
return fmt.Errorf("Riverbed AppInternals agent JAR not found after installation: %w", err)
// constructAgentJarPath can be skipped here and do it only in finalize, but it can be left as a double check
// if jar path exists after the dependency install
err = r.constructAgentJarPath(agentDir)
if err != nil {
return fmt.Errorf("riverbed appinternals agent JAR not found during supply: %w", err)
}
r.agentPath = agentJarPath

r.context.Log.Info("Riverbed AppInternals agent %s installed", dep.Version)
return nil
}

// Finalize configures the Riverbed AppInternals agent
func (r *RiverbedAppInternalsAgentFramework) Finalize() error {
if r.agentPath == "" {
return nil
agentDir := filepath.Join(r.context.Stager.DepDir(), "riverbed_appinternals_agent")
err := r.constructAgentJarPath(agentDir)
if err != nil {
return fmt.Errorf("riverbed appinternals agent JAR not found during finalize: %w", err)
}

r.context.Log.BeginStep("Configuring Riverbed AppInternals agent")
Expand Down Expand Up @@ -214,3 +216,13 @@ func (r *RiverbedAppInternalsAgentFramework) getApplicationName() string {

return ""
}

func (r *RiverbedAppInternalsAgentFramework) constructAgentJarPath(agentDir string) error {
// Find the installed agent directory (contains lib/rvbd-agent.jar)
agentJarPath := filepath.Join(agentDir, "lib", "rvbd-agent.jar")
if _, err := os.Stat(agentJarPath); err != nil {
return fmt.Errorf("agent jar not found after installation: %w", err)
}
r.agentPath = agentJarPath
return nil
}
Loading