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

Log Levels View #1138

Merged
merged 7 commits into from
Dec 20, 2023
Merged

Log Levels View #1138

merged 7 commits into from
Dec 20, 2023

Conversation

vudayani
Copy link
Collaborator

@vudayani vudayani commented Nov 2, 2023

No description provided.

@pivotal-cla
Copy link

@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.

Copy link
Contributor

@BoykoAlex BoykoAlex left a 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 {
Copy link
Contributor

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);
Copy link
Contributor

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")
Copy link
Contributor

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?

Copy link
Collaborator Author

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";
Copy link
Contributor

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)

Copy link
Collaborator Author

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)
Copy link
Contributor

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...

Copy link
Contributor

@BoykoAlex BoykoAlex left a 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});
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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);
Copy link
Contributor

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 vudayani changed the title Draft: Log Levels Log Levels View Dec 19, 2023
@BoykoAlex
Copy link
Contributor

@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.

@martinlippert
Copy link
Member

@vudayani-vmw @BoykoAlex Keep in mind that newly added copyright headers should refer to Broadcom, Inc. instead of VMware, Inc.

@vudayani vudayani marked this pull request as ready for review December 19, 2023 16:21
@BoykoAlex
Copy link
Contributor

LGTM - squashing and merging. Thanks @vudayani-vmw - great job!

@BoykoAlex BoykoAlex merged commit e319e43 into spring-projects:main Dec 20, 2023
1 check failed
@martinlippert martinlippert added this to the 4.21.1.RELEASE milestone Dec 21, 2023
@martinlippert martinlippert added for: vscode something that is specific for VSCode theme: live-data type: enhancement labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: vscode something that is specific for VSCode theme: live-data type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants