-
Notifications
You must be signed in to change notification settings - Fork 208
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
Log Levels View #1138
Log Levels View #1138
Conversation
@vudayani-vmw Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial review... don't think I follow everything in there... I think i was most confused by getLoggers
and getLoggersData
thing...
@@ -0,0 +1,72 @@ | |||
package org.springframework.ide.vscode.commons.protocol; | |||
|
|||
public class LiveProcessLoggersSummary { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we switch this to record? :-) Looks like fields are not immutable thus seems to be a good candidate...
void liveProcessLoggersDataUpdated(LiveProcessSummary processKey); | ||
|
||
@JsonNotification("sts/liveprocess/loglevel/updated") | ||
void liveProcessLogLevelUpdated(LiveProcessLoggersSummary processKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter name to adjust
@@ -51,6 +51,12 @@ public interface STS4LanguageClient extends LanguageClient, SpringIndexLanguageC | |||
|
|||
@JsonNotification("sts/liveprocess/gcpauses/metrics/updated") | |||
void liveProcessGcPausesMetricsDataUpdated(LiveProcessSummary processKey); | |||
|
|||
@JsonNotification("sts/liveprocess/loggers/updated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these 2 methods are doing? My guess is once action is executed to refresh running process live data notification is sent out to the client to refresh UI etc? I see similar method for metrics but forgot the purpose :-\ I might figure it out while reviewing the rest of the code though ;-)
Does the notification with LiveProcessLoggersSummary
parameter simply lets IDE know that the log level that was attempted to be changed with a post request or JMX Bean operation has indeed changed? Is that it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these 2 methods are doing? My guess is once action is executed to refresh running process live data notification is sent out to the client to refresh UI etc? I see similar method for metrics but forgot the purpose :-\ I might figure it out while reviewing the rest of the code though ;-)
Yes, that's correct. It is to send notification to the client that actuator data is available. Fetch and refresh the UI.
Does the notification with LiveProcessLoggersSummary parameter simply lets IDE know that the log level that was attempted to be changed with a post request or JMX Bean operation has indeed changed? Is that it?
Yes, it just contains additional fields to let IDE know which package and log level was updated. This information is displayed as a notification in the IDE.
I didn't want to store this data and make another call to fetch the changed log level info to display in the UI as a notification.
@@ -43,6 +44,9 @@ public class SpringProcessCommandHandler { | |||
private static final String COMMAND_LIST_CONNECTED = "sts/livedata/listConnected"; | |||
private static final String COMMAND_GET_METRICS = "sts/livedata/get/metrics"; | |||
private static final String COMMAND_GET_REFRESH_METRICS = "sts/livedata/refresh/metrics"; | |||
private static final String COMMAND_GET_LOGGERS = "sts/livedata/getLoggers"; | |||
private static final String COMMAND_FETCH_LOGGERS_DATA = "sts/livedata/fetch/loggersData"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... What's the loggers data for? Is this something to show in the UI? Something that is not included into loggers data structure already? (Might figure this out by the end of the review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The COMMAND_GET_LOGGERS = "sts/livedata/getLoggers"
- is to make a get request or JMX Bean operation to get the list of loggers async. Once the loggers are fetched it is stored in a loggersData map and a notification is sent to the client that logger data is available.
The COMMAND_FETCH_LOGGERS_DATA = "sts/livedata/fetch/loggersData"
- is used to fetch this data from the map and show it in the IDE
The naming convention above is bad i guess and it is causing the confusion.
context.subscriptions.push( | ||
VSCode.commands.registerCommand('vscode-spring-boot.set.log-levels', () => { | ||
if (client.isRunning()) { | ||
client.onNotification(LiveProcessLoggersUpdatedNotification.type, getLoggersList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... is this inside the command handler? Might not be a good idea to register notification listeners every time command is executed...
1f17d4d
to
2072632
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally all looks good to me. I only had one comment about the code. The tests started passign for me once i rebased on the latest from main branch. I have tried the UI in the vscode - it worked just fine. Thus, overall, it all looks good.
There is however a broader question i had. My understanding is that we cache the loggers once receive them via JMX/Actuator endpoint and send a notification that data is there. I was thinking that perhaps unlike with memory metrics and other things we don't need to cache the loggers data? If the plan is just list current loggers in the UI for the set logger level action then we could just have a fetch command to show them within the action UI and then forget. While loggers are fetched indefinite progress bar is shown in the show pick UI with some message that loggers are fetched etc. What do you think?
const chosenPackage = await VSCode.window.showQuickPick(items); | ||
if (chosenPackage) { | ||
const chosenlogLevel = await VSCode.window.showQuickPick(loggers.levels); | ||
const changeLogLevel = await VSCode.commands.executeCommand('sts/livedata/configure/logLevel', {"endpoint": "loggers"}, process, chosenPackage, {"configuredLevel":chosenlogLevel}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like {"endpoint": "loggers"}
is a redundant piece of info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. I will start working on it and aim to have the updates ready by next week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated getLoggers and removed caching logic. A progress bar is shown in the status bar of the window when loggers are being fetched.
if (connector != null) { | ||
final IndefiniteProgressTask progressTask = getProgressTask( | ||
"spring-process-connector-service-get-loggers-data" + springProcessParams.getProcessKey(), "Loggers", null); | ||
System.out.println(progressTask); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch out for these System.out.println
statements in the code :-) They are okay when you connect to LS via socket but once you build a VSCode extension and launch it without connecting to LS the comm goes over System in/out and that print statement would just corrupt the JSON RPC comm and shutdown the LS for unknown reason ;-)
So, yes, these statement would need to go or replaced with log statement :-)
I'm guilty for leaving System.out.println
multiple times ;-)
@vudayani-vmw Just tried it today. Seems to be working and looks good overall. I'd just add the copyright headers for new files, mark the PR as "ready" and merge it. |
@vudayani-vmw @BoykoAlex Keep in mind that newly added copyright headers should refer to |
LGTM - squashing and merging. Thanks @vudayani-vmw - great job! |
No description provided.