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

Fix MWTELE 127 130 131 #20

Merged
merged 3 commits into from
Dec 6, 2023
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
17 changes: 11 additions & 6 deletions src/main/java/com/redhat/insights/agent/AgentMain.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Copyright (C) Red Hat 2023 */
package com.redhat.insights.agent;

import com.redhat.insights.InsightsException;
import com.redhat.insights.InsightsReportController;
import com.redhat.insights.http.InsightsFileWritingClient;
import com.redhat.insights.http.InsightsHttpClient;
Expand Down Expand Up @@ -70,7 +71,7 @@ public static void startAgent(String agentArgs, Instrumentation instrumentation)
return;
}

BlockingQueue<JarInfo> jarsToSend = new LinkedBlockingQueue<>();
final BlockingQueue<JarInfo> jarsToSend = new LinkedBlockingQueue<>();
try {
logger.info("Starting Red Hat Insights client");
new AgentMain(config, jarsToSend).start();
Expand Down Expand Up @@ -118,7 +119,6 @@ static boolean shouldContinue(AgentConfiguration config) {
/**
* Parse the agent arguments from the form "key1=value1;key2=value2;..."
*
* @param logger
* @param agentArgs
* @return
*/
Expand Down Expand Up @@ -162,17 +162,22 @@ private static boolean shouldLookForCerts(AgentConfiguration config) {

private void start() {
final InsightsReport report = AgentBasicReport.of(configuration);
final PEMSupport pem = new PEMSupport(logger, configuration);

Supplier<InsightsHttpClient> httpClientSupplier;
if (configuration.isDebug() || configuration.isFileOnly()) {
httpClientSupplier = () -> new InsightsFileWritingClient(logger, configuration);
} else {
final PEMSupport pem = new PEMSupport(logger, configuration);
httpClientSupplier =
() -> new InsightsAgentHttpClient(configuration, () -> pem.createTLSContext());
}
final InsightsReportController controller =
InsightsReportController.of(logger, configuration, report, httpClientSupplier, waitingJars);
controller.generate();
try {
final InsightsReportController controller =
InsightsReportController.of(
logger, configuration, report, httpClientSupplier, waitingJars);
controller.generate();
} catch (InsightsException e) {
logger.info("Unable to start Red Hat Insights client: " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class AgentSubreport implements InsightsSubreport {

static {
activeGuesses.put("org.springframework.boot.SpringApplication", __ -> "Spring Boot");
activeGuesses.put("org.springframework.boot.loader.Launcher", __ -> "Spring Boot");
activeGuesses.put("org.jboss.modules.Module", AgentSubreport::fingerprintJBoss);
activeGuesses.put(
"io.quarkus.bootstrap.runner.QuarkusEntryPoint", AgentSubreport::fingerprintQuarkus);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/redhat/insights/agent/Attach.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void main(String[] args) {
System.exit(1);
}
URL jarUrl = AgentMain.class.getProtectionDomain().getCodeSource().getLocation();
System.out.println("Trying to attach: " + jarUrl);
// System.out.println("Trying to attach: " + jarUrl);
String agentJar = jarUrl.toExternalForm().replaceFirst("^file:", "");

String pid = args[0];
Expand All @@ -26,9 +26,9 @@ public static void main(String[] args) {
VirtualMachine vm = VirtualMachine.attach(pid);
vm.loadAgent(agentJar, options);
vm.detach();
} catch (IOException e) {
} catch (AgentLoadException | IOException e) {
// Probable Java version mismatch, ignore
} catch (AgentLoadException | AttachNotSupportedException | AgentInitializationException e) {
} catch (AttachNotSupportedException | AgentInitializationException e) {
throw new RuntimeException(e);
}
}
Expand Down