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

chore(log): update log levels #411

Merged
merged 1 commit into from
Jun 11, 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
11 changes: 5 additions & 6 deletions src/main/java/io/cryostat/agent/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -189,7 +189,7 @@ private static List<String> 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());
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
});
Expand Down Expand Up @@ -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);
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/cryostat/agent/CryostatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public CompletableFuture<Boolean> checkRegistration(PluginInfo pluginInfo) {
+ pluginInfo.getId()
+ "?token="
+ pluginInfo.getToken()));
log.info("{}", req);
log.trace("{}", req);
return supply(req, (res) -> logResponse(req, res)).thenApply(this::isOkStatus);
}

Expand All @@ -131,7 +131,7 @@ public CompletableFuture<PluginInfo> 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),
Expand Down Expand Up @@ -189,7 +189,7 @@ public CompletableFuture<Integer> 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) -> {
Expand All @@ -210,7 +210,7 @@ public CompletableFuture<Integer> submitCredentialsIfRequired(

private CompletableFuture<Integer> 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) -> {
Expand Down Expand Up @@ -279,7 +279,7 @@ private CompletableFuture<Integer> 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(
Expand Down Expand Up @@ -321,7 +321,7 @@ public CompletableFuture<Void> 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);
}

Expand All @@ -334,7 +334,7 @@ public CompletableFuture<Void> 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);
Expand All @@ -355,7 +355,7 @@ public CompletableFuture<Void> 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);
Expand Down Expand Up @@ -431,7 +431,7 @@ public CompletableFuture<Void> upload(
req,
(res) -> {
Instant finish = Instant.now();
log.info(
log.trace(
"{} {} ({} -> {}): {}/{}",
req.getMethod(),
res.getStatusLine().getStatusCode(),
Expand All @@ -445,7 +445,7 @@ public CompletableFuture<Void> 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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/cryostat/agent/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void start() {
.get();
} catch (ExecutionException
| InterruptedException e) {
log.warn(
log.error(
"Could not check registration status",
e);
}
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -270,7 +270,7 @@ private Set<DiscoveryNode> 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 =
Expand Down Expand Up @@ -326,7 +326,7 @@ void stop() {}

CompletableFuture<Void> 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())
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/cryostat/agent/WebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/cryostat/agent/harvest/Harvester.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 -> {
Expand Down Expand Up @@ -267,7 +267,7 @@ public Future<Void> 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();
Expand Down Expand Up @@ -363,7 +363,7 @@ private Future<Void> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public List<SmartTrigger> 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.");
}
}
}
Expand Down
Loading