diff --git a/src/main/java/io/cryostat/agent/Agent.java b/src/main/java/io/cryostat/agent/Agent.java index 7b60c0a7..e127bad2 100644 --- a/src/main/java/io/cryostat/agent/Agent.java +++ b/src/main/java/io/cryostat/agent/Agent.java @@ -130,7 +130,7 @@ public Integer call() log.trace("agentmain arg: \"{}\"", agentmainArg); for (String pid : pids) { VirtualMachine vm = VirtualMachine.attach(pid); - log.info("Injecting agent into PID {}", pid); + log.trace("Injecting agent into PID {}", pid); try { vm.loadAgent(Path.of(selfJarLocation()).toAbsolutePath().toString(), agentmainArg); } finally { @@ -189,7 +189,7 @@ private static List getAttachPid(String pidSpec) { } return vms.stream() .filter(vmFilter) - .peek(vmd -> log.info("Attaching to VM: {} {}", vmd.displayName(), vmd.id())) + .peek(vmd -> log.trace("Attaching to VM: {} {}", vmd.displayName(), vmd.id())) .map(VirtualMachineDescriptor::id) .collect(Collectors.toList()); } @@ -200,11 +200,10 @@ static URI selfJarLocation() throws URISyntaxException { @Override public void accept(AgentArgs args) { - log.info("Cryostat Agent starting..."); args.getProperties() .forEach( (k, v) -> { - log.info("Set system property {} = {}", k, v); + log.trace("Set system property {} = {}", k, v); System.setProperty(k, v); }); AgentExitHandler agentExitHandler = null; @@ -265,7 +264,7 @@ public void accept(AgentArgs args) { log.info("Registration state: {}", evt.state); break; default: - log.error("Unknown registration state: {}", evt.state); + log.warn("Unknown registration state: {}", evt.state); break; } }); @@ -378,7 +377,7 @@ void setOldHandler(Signal signal, SignalHandler oldHandler) { @Override public void handle(Signal sig) { - log.info("Caught SIG{}({})", sig.getName(), sig.getNumber()); + log.debug("Caught SIG{}({})", sig.getName(), sig.getNumber()); if (needsCleanup.getAndSet(false)) { performCleanup(sig); } diff --git a/src/main/java/io/cryostat/agent/CryostatClient.java b/src/main/java/io/cryostat/agent/CryostatClient.java index a9ebc940..9768e17b 100644 --- a/src/main/java/io/cryostat/agent/CryostatClient.java +++ b/src/main/java/io/cryostat/agent/CryostatClient.java @@ -120,7 +120,7 @@ public CompletableFuture checkRegistration(PluginInfo pluginInfo) { + pluginInfo.getId() + "?token=" + pluginInfo.getToken())); - log.info("{}", req); + log.trace("{}", req); return supply(req, (res) -> logResponse(req, res)).thenApply(this::isOkStatus); } @@ -131,7 +131,7 @@ public CompletableFuture register( new RegistrationInfo( pluginInfo.getId(), realm, callback, pluginInfo.getToken()); HttpPost req = new HttpPost(baseUri.resolve(DISCOVERY_API_PATH)); - log.info("{}", req); + log.trace("{}", req); req.setEntity( new StringEntity( mapper.writeValueAsString(registrationInfo), @@ -189,7 +189,7 @@ public CompletableFuture submitCredentialsIfRequired( }); } HttpGet req = new HttpGet(baseUri.resolve(CREDENTIALS_API_PATH + "/" + prevId)); - log.info("{}", req); + log.trace("{}", req); return supply(req, (res) -> logResponse(req, res)) .handle( (v, t) -> { @@ -210,7 +210,7 @@ public CompletableFuture submitCredentialsIfRequired( private CompletableFuture queryExistingCredentials(URI callback) { HttpGet req = new HttpGet(baseUri.resolve(CREDENTIALS_API_PATH)); - log.info("{}", req); + log.trace("{}", req); return supply(req, (res) -> logResponse(req, res)) .handle( (res, t) -> { @@ -279,7 +279,7 @@ private CompletableFuture submitCredentials( selfMatchExpression(callback), ContentType.TEXT_PLAIN)) .build()); - log.info("{}", req); + log.trace("{}", req); req.setEntity(entityBuilder.build()); return supply(req, (res) -> logResponse(req, res)) .thenApply( @@ -321,7 +321,7 @@ public CompletableFuture deleteCredentials(int id) { return CompletableFuture.completedFuture(null); } HttpDelete req = new HttpDelete(baseUri.resolve(CREDENTIALS_API_PATH + "/" + id)); - log.info("{}", req); + log.trace("{}", req); return supply(req, (res) -> logResponse(req, res)).thenApply(res -> null); } @@ -334,7 +334,7 @@ public CompletableFuture deregister(PluginInfo pluginInfo) { + pluginInfo.getId() + "?token=" + pluginInfo.getToken())); - log.info("{}", req); + log.trace("{}", req); return supply(req, (res) -> logResponse(req, res)) .thenApply(res -> assertOkStatus(req, res)) .thenApply(res -> null); @@ -355,7 +355,7 @@ public CompletableFuture update( new StringEntity( mapper.writeValueAsString(subtree), ContentType.APPLICATION_JSON)); - log.info("{}", req); + log.trace("{}", req); return supply(req, (res) -> logResponse(req, res)) .thenApply(res -> assertOkStatus(req, res)) .thenApply(res -> null); @@ -431,7 +431,7 @@ public CompletableFuture upload( req, (res) -> { Instant finish = Instant.now(); - log.info( + log.trace( "{} {} ({} -> {}): {}/{}", req.getMethod(), res.getStatusLine().getStatusCode(), @@ -445,7 +445,7 @@ public CompletableFuture upload( } private HttpResponse logResponse(HttpRequestBase req, HttpResponse res) { - log.info("{} {} : {}", req.getMethod(), req.getURI(), res.getStatusLine().getStatusCode()); + log.trace("{} {} : {}", req.getMethod(), req.getURI(), res.getStatusLine().getStatusCode()); return res; } diff --git a/src/main/java/io/cryostat/agent/Registration.java b/src/main/java/io/cryostat/agent/Registration.java index 9da397f5..ecfdf432 100644 --- a/src/main/java/io/cryostat/agent/Registration.java +++ b/src/main/java/io/cryostat/agent/Registration.java @@ -157,7 +157,7 @@ void start() { .get(); } catch (ExecutionException | InterruptedException e) { - log.warn( + log.error( "Could not check registration status", e); } @@ -260,7 +260,7 @@ private void tryUpdate() { try { f.get(); } catch (ExecutionException | InterruptedException e) { - log.warn("Failed to update", e); + log.error("Failed to update", e); } } @@ -270,7 +270,7 @@ private Set defineSelf() throws UnknownHostException, URISyntaxEx long pid = ProcessHandle.current().pid(); String javaMain = System.getProperty("sun.java.command", System.getenv("JAVA_MAIN_CLASS")); if (StringUtils.isBlank(javaMain)) { - log.error("Unable to determine application mainclass"); + log.warn("Unable to determine application mainclass"); javaMain = null; } long startTime = @@ -326,7 +326,7 @@ void stop() {} CompletableFuture deregister() { if (!this.pluginInfo.isInitialized()) { - log.info("Deregistration requested before registration complete!"); + log.warn("Deregistration requested before registration complete!"); return CompletableFuture.completedFuture(null); } return cryostat.deleteCredentials(webServer.getCredentialId()) diff --git a/src/main/java/io/cryostat/agent/WebServer.java b/src/main/java/io/cryostat/agent/WebServer.java index a7862855..5ee7cf6f 100644 --- a/src/main/java/io/cryostat/agent/WebServer.java +++ b/src/main/java/io/cryostat/agent/WebServer.java @@ -211,10 +211,10 @@ public void doFilter(HttpExchange exchange, Chain chain) throws IOException { long start = System.nanoTime(); String requestMethod = exchange.getRequestMethod(); String path = exchange.getRequestURI().getPath(); - log.info("{} {}", requestMethod, path); + log.trace("{} {}", requestMethod, path); chain.doFilter(exchange); long elapsed = System.nanoTime() - start; - log.info( + log.trace( "{} {} : {} {}ms", requestMethod, path, @@ -262,9 +262,9 @@ public void doFilter(HttpExchange exchange, Chain chain) throws IOException { } } if (negotiatedEncoding == null) { - log.info("Using no encoding"); + log.trace("Using no encoding"); } else { - log.info("Using '{}' encoding", negotiatedEncoding); + log.trace("Using '{}' encoding", negotiatedEncoding); exchange.getResponseHeaders().put("Content-Encoding", List.of(negotiatedEncoding)); } chain.doFilter(exchange); diff --git a/src/main/java/io/cryostat/agent/harvest/Harvester.java b/src/main/java/io/cryostat/agent/harvest/Harvester.java index f4cce7db..82644d75 100644 --- a/src/main/java/io/cryostat/agent/harvest/Harvester.java +++ b/src/main/java/io/cryostat/agent/harvest/Harvester.java @@ -118,10 +118,10 @@ public void start() { } this.running = true; if (StringUtils.isBlank(template)) { - log.info("Template not specified"); + log.warn("Template not specified"); } if (maxFiles <= 0) { - log.info( + log.warn( "Maximum number of files to keep within target is {} <= 0", maxFiles); } @@ -201,7 +201,7 @@ public void stop() { @Override public void recordingStateChanged(Recording recording) { - log.info("{}({}) {}", recording.getName(), recording.getId(), recording.getState().name()); + log.debug("{}({}) {}", recording.getName(), recording.getId(), recording.getState().name()); getTrackedRecordingById(recording.getId()) .ifPresent( tr -> { @@ -267,7 +267,7 @@ public Future exitUpload() { try { uploadOngoing(PushType.ON_STOP, exitSettings).get(); } catch (ExecutionException | InterruptedException e) { - log.warn("Exit upload failed", e); + log.error("Exit upload failed", e); throw new CompletionException(e); } finally { safeCloseCurrentRecording(); @@ -363,7 +363,7 @@ private Future uploadOngoing(PushType pushType, RecordingSettings settings Files.deleteIfExists(exitPath); log.trace("Deleted temp file {}", exitPath); } catch (IOException ioe) { - log.warn("Failed to clean up snapshot dump file", ioe); + log.error("Failed to clean up snapshot dump file", ioe); } }); } catch (IOException e) { diff --git a/src/main/java/io/cryostat/agent/triggers/TriggerParser.java b/src/main/java/io/cryostat/agent/triggers/TriggerParser.java index 9c00473d..3ecc061a 100644 --- a/src/main/java/io/cryostat/agent/triggers/TriggerParser.java +++ b/src/main/java/io/cryostat/agent/triggers/TriggerParser.java @@ -60,7 +60,7 @@ public List parse(String str) { log.error("Failed to parse trigger duration constraint", dtpe); } } else { - log.error("Template " + templateName + " not found. Skipping trigger."); + log.warn("Template " + templateName + " not found. Skipping trigger."); } } }