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: added thread logging info for plugins #36077

Merged
merged 10 commits into from
Sep 5, 2024

Conversation

NilanshBansal
Copy link
Contributor

@NilanshBansal NilanshBansal commented Sep 3, 2024

Description

This PR adds logging in plugins to detect the following:

  • Detect multithreading issues (Added Java Thread information to the logs at different places in the code)
  • Check if the execution is correctly scheduled on elastic scheduler threads (Added thread info logs within the subscribed code)
  • Time taken by objectMapper blocking calls within the plugins (Added stopwatch log to check the same)
  • Fixed the old logs within the plugins which were not getting logged due to this issue (Replaced log.debug for the most important logs to Sysout, so that we don't miss out on essential logs)

Fixes #35568

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10719357725
Commit: c63aa4c
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 05 Sep 2024 11:48:30 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced logging capabilities across various plugins, providing real-time feedback on method calls and execution flow.
    • Introduced performance monitoring with execution time tracking in several plugins.
  • Bug Fixes

    • Improved error handling visibility by modifying logging approaches, allowing for better tracking of issues during execution.
  • Documentation

    • Updated logging methods to standard output, facilitating easier debugging and monitoring in production environments.

Copy link
Contributor

coderabbitai bot commented Sep 3, 2024

Walkthrough

The changes across multiple plugin files involve the addition of logging statements that print the current thread's name and method execution details to the console. This enhancement aims to improve visibility into the execution flow of various methods, particularly in multi-threaded environments, without altering the core functionality of the plugins.

Changes

Files Change Summary
.../mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java Added logging statements and integrated performance monitoring with Stopwatch.
.../mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java Replaced logging statements with console output and added performance tracking.
.../mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java Enhanced logging for method calls and integrated performance monitoring.
.../postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java Enhanced logging for method executions and integrated performance monitoring.
.../saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java Enhanced logging and performance tracking within the execute method.

Assessment against linked issues

Objective Addressed Explanation
Add Java thread information in the Plugin Module (#35568)

Poem

In the code where plugins play,
Threads now whisper what they say.
Logging brightens the darkened path,
Helping us measure the aftermath.
With every call, a tale unfolds,
In console light, the truth it holds. 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration Query & JS Pod Issues related to the query & JS Pod Stability Issue Every issue handle by Stability Pod Stability Pod For all issues/tasks to be prioritized under Stability pod Task A simple Todo labels Sep 3, 2024
@NilanshBansal NilanshBansal changed the title chore: added thread logging info for 10 plugins chore: added thread logging info for plugins Sep 3, 2024
Copy link

github-actions bot commented Sep 3, 2024

Failed server tests

  • com.appsmith.server.git.CommonGitServiceCETest#isBranchMergeable_checkMergingWithRemoteBranch_throwsUnsupportedOperationException

Copy link

github-actions bot commented Sep 4, 2024

Failed server tests

  • com.appsmith.server.git.CommonGitServiceCETest#updateGitMetadata_EmptyData_Success

@NilanshBansal NilanshBansal marked this pull request as ready for review September 4, 2024 15:36
@NilanshBansal NilanshBansal added the ok-to-test Required label for CI label Sep 4, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

Outside diff range, codebase verification and nitpick comments (72)
app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java (3)

88-89: Use a logger instead of System.out.println().

The print statements are added for logging and debugging purposes, which is a good practice. However, it's recommended to use a proper logging framework (e.g., SLF4J) instead of System.out.println() for better log management and performance.

Consider replacing the print statements with logger statements:

-String printMessage = Thread.currentThread().getName() + ": execute() called for Saas plugin.";
-System.out.println(printMessage);
+logger.debug("execute() called for Saas plugin. [Thread: {}]", Thread.currentThread().getName());

138-143: Good performance monitoring, but use a logger.

Measuring the time taken by the object mapper to serialize the connection object is a good practice for performance monitoring. The Stopwatch class is used effectively for this purpose.

However, as mentioned earlier, it's recommended to use a proper logging framework instead of System.out.println() for better log management and performance.

Consider replacing the print statement with a logger statement:

-System.out.println(
-        Thread.currentThread().getName() + ": objectMapper writing value as string for Saas plugin.");
+logger.debug("objectMapper writing value as string for Saas plugin. [Thread: {}]", Thread.currentThread().getName());

156-162: Good performance monitoring, but use a logger.

Measuring the time taken by the object mapper to deserialize the response body into an ActionExecutionResult object is a good practice for performance monitoring. The Stopwatch class is used effectively for this purpose.

However, as mentioned earlier, it's recommended to use a proper logging framework instead of System.out.println() for better log management and performance.

Consider replacing the print statements with logger statements:

-System.out.println(Thread.currentThread().getName()
-        + ": objectMapper reading value as string for Saas plugin.");
+logger.debug("objectMapper reading value as string for Saas plugin. [Thread: {}]", Thread.currentThread().getName());
app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java (3)

75-77: Consider using a proper logging framework instead of System.out.println.

While the added print statement provides useful information about the execution flow, it's generally recommended to use a proper logging framework (e.g., SLF4J) instead of System.out.println in production code. This allows for better control over log levels, formatting, and destinations.

Here's an example of how you could replace the print statement with a logger:

-            String printMessage = Thread.currentThread().getName()
-                    + ": executeParameterized() called for RestAPI plugin. Executing the API call.";
-            System.out.println(printMessage);
+            log.info("executeParameterized() called for RestAPI plugin. Executing the API call.");

Make sure to declare and initialize the logger at the class level:

private static final Logger log = LoggerFactory.getLogger(RestApiPlugin.class);

137-139: Consider using a proper logging framework instead of System.out.println.

As mentioned in the previous comment, it's recommended to use a proper logging framework (e.g., SLF4J) instead of System.out.println in production code. This allows for better control over log levels, formatting, and destinations.

Here's an example of how you could replace the print statement with a logger:

-            String printMessage = Thread.currentThread().getName()
-                    + ": executeCommon() called for RestAPI plugin. Executing the API call.";
-            System.out.println(printMessage);
+            log.info("executeCommon() called for RestAPI plugin. Executing the API call.");

Make sure to declare and initialize the logger at the class level:

private static final Logger log = LoggerFactory.getLogger(RestApiPlugin.class);

218-220: Use the logger with an appropriate log level instead of System.out.println for logging errors.

Replacing the debug log statement with a print statement modifies the logging mechanism from a debug level to a standard output, which may affect how errors are monitored in production environments. It's generally recommended to use appropriate log levels and avoid using System.out.println for logging errors.

Consider using the logger with an error log level:

-                        System.out.println(String.format(
-                                "An error has occurred while trying to run the API query for url: %s, path: %s",
-                                datasourceConfiguration.getUrl(), actionConfiguration.getPath()));
+                        log.error("An error has occurred while trying to run the API query for url: {}, path: {}",
+                                datasourceConfiguration.getUrl(), actionConfiguration.getPath());

This way, the error message will be logged using the appropriate log level, making it easier to monitor and handle errors in production environments.

app/server/appsmith-plugins/elasticSearchPlugin/src/main/java/com/external/plugins/ElasticSearchPlugin.java (4)

83-84: Consider using a logger instead of System.out.println.

While the print statement is helpful for tracing the execution flow, it's generally recommended to use a logging framework (e.g., SLF4J) instead of System.out.println for production code. This allows for better control over log levels and destinations.

Replace the print statement with a logger:

-            String printMessage = Thread.currentThread().getName() + ": execute() called for ElasticSearch plugin.";
-            System.out.println(printMessage);
+            log.debug("{}: execute() called for ElasticSearch plugin.", Thread.currentThread().getName());

91-92: Consider using a logger instead of System.out.println.

As mentioned earlier, it's recommended to use a logging framework instead of System.out.println for production code.

Replace the print statement with a logger:

-                        System.out.println(Thread.currentThread().getName()
-                                + ": creating action execution result from ElasticSearch plugin.");
+                        log.debug("{}: creating action execution result from ElasticSearch plugin.", Thread.currentThread().getName());

174-175: Consider using a logger instead of System.out.println.

As mentioned earlier, it's recommended to use a logging framework instead of System.out.println for production code.

Replace the print statement with a logger:

-                        System.out.println(Thread.currentThread().getName()
-                                + ": setting the request in the result to be returned from ElasticSearch plugin.");
+                        log.debug("{}: setting the request in the result to be returned from ElasticSearch plugin.", Thread.currentThread().getName());

201-203: Consider using a logger instead of System.out.println.

As mentioned earlier, it's recommended to use a logging framework instead of System.out.println for production code. This applies to the print statements in the datasourceCreate, validateDatasource, testDatasource, and getEndpointIdentifierForRateLimit methods as well.

Replace the print statements with loggers:

-            String printMessage =
-                    Thread.currentThread().getName() + ": datasourceCreate() called for ElasticSearch plugin.";
-            System.out.println(printMessage);
+            log.debug("{}: datasourceCreate() called for ElasticSearch plugin.", Thread.currentThread().getName());

-            String printMessage =
-                    Thread.currentThread().getName() + ": validateDatasource() called for ElasticSearch plugin.";
-            System.out.println(printMessage);
+            log.debug("{}: validateDatasource() called for ElasticSearch plugin.", Thread.currentThread().getName());

-            String printMessage =
-                    Thread.currentThread().getName() + ": testDatasource() called for ElasticSearch plugin.";
-            System.out.println(printMessage);
+            log.debug("{}: testDatasource() called for ElasticSearch plugin.", Thread.currentThread().getName());

-            String printMessage = Thread.currentThread().getName()
-                    + ": getEndpointIdentifierForRateLimit() called for ElasticSearch plugin.";
-            System.out.println(printMessage);
+            log.debug("{}: getEndpointIdentifierForRateLimit() called for ElasticSearch plugin.", Thread.currentThread().getName());

Also applies to: 258-260, 285-287, 337-339

app/server/appsmith-plugins/anthropicPlugin/src/main/java/com/external/plugins/AnthropicPlugin.java (4)

77-78: Consider using a logging framework instead of System.out.println.

While the added logging statement provides useful information about the thread and method call, it's generally recommended to use a proper logging framework like SLF4J or Log4j instead of directly printing to the console using System.out.println.

Logging frameworks offer several advantages, such as:

  • Configurable log levels to control the verbosity of logs in different environments
  • Ability to direct logs to various outputs (console, files, etc.)
  • Structured logging for better searchability and analysis

Since the class already has an @Slf4j annotation, you can simply replace the System.out.println with log.info or log.debug to leverage the SLF4J logging framework.

-            String printMessage = Thread.currentThread().getName() + ": testDatasource() called for Anthropic plugin.";
-            System.out.println(printMessage);
+            log.info("testDatasource() called for Anthropic plugin on thread: {}", Thread.currentThread().getName());

116-118: Use a logging framework instead of System.out.println.

As mentioned in the previous comment, it's a good practice to use a logging framework like SLF4J instead of System.out.println. Please replace the System.out.println statement with an appropriate logging statement using the log object.

-            String printMessage =
-                    Thread.currentThread().getName() + ": executeParameterized() called for Anthropic plugin.";
-            System.out.println(printMessage);
+            log.info("executeParameterized() called for Anthropic plugin on thread: {}", Thread.currentThread().getName());

257-258: Replace System.out.println with a logging framework.

Let's continue the pattern of using the SLF4J logging framework instead of System.out.println. Please update the logging statement to use the log object.

-            String printMessage = Thread.currentThread().getName() + ": trigger() called for Anthropic plugin.";
-            System.out.println(printMessage);
+            log.info("trigger() called for Anthropic plugin on thread: {}", Thread.currentThread().getName());

320-322: Stick to using the logging framework.

For consistency, let's replace the System.out.println statement with a proper logging statement using the log object, just like in the previous comments.

-            String printMessage =
-                    Thread.currentThread().getName() + ": validateDatasource() called for Anthropic plugin.";
-            System.out.println(printMessage);
+            log.info("validateDatasource() called for Anthropic plugin on thread: {}", Thread.currentThread().getName());
app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java (1)

284-284: Include exception details in the log message.

It's great that you're logging an error message when an exception occurs while destroying the Jedis pool. To make the log message more informative, consider including the exception details in the log message.

Here's a suggestion:

- System.out.println("Error destroying Jedis pool.");
+ System.out.println("Error destroying Jedis pool: " + e.getMessage());

By including the exception message, it will be easier to identify the specific cause of the error when debugging.

app/server/appsmith-plugins/graphqlPlugin/src/main/java/com/external/plugins/GraphQLPlugin.java (2)

88-90: Logging statements enhance traceability but use a proper logging framework.

Hi there! The addition of logging statements to track the execution flow is a good practice for debugging and monitoring. However, I recommend using a proper logging framework like SLF4J instead of System.out.println(). This will give you more control over the log levels and allow you to easily disable logging in production environments.

Here's how you can refactor the code to use SLF4J:

+private static final Logger logger = LoggerFactory.getLogger(GraphQLPlugin.class);
 
 public Mono<ActionExecutionResult> executeParameterized(
         APIConnection connection,
         ExecuteActionDTO executeActionDTO,
         DatasourceConfiguration datasourceConfiguration,
         ActionConfiguration actionConfiguration) {

-    String printMessage =
-            Thread.currentThread().getName() + ": executeParameterized() called for GraphQL plugin.";
-    System.out.println(printMessage);
+    logger.debug("{}: executeParameterized() called for GraphQL plugin.", Thread.currentThread().getName());
     
     // ...
 }

Make sure to add the necessary imports:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

167-168: Logging statements enhance traceability but use a proper logging framework.

Great job adding logging statements to track the execution flow! This will definitely help with debugging and monitoring. However, similar to the previous comment, I suggest using a proper logging framework like SLF4J instead of System.out.println(). This will give you more flexibility and control over the logging behavior.

Here's how you can refactor the code to use SLF4J:

 public Mono<ActionExecutionResult> executeCommon(
         APIConnection apiConnection,
         DatasourceConfiguration datasourceConfiguration,
         ActionConfiguration actionConfiguration,
         List<Map.Entry<String, String>> insertedParams) {

-    String printMessage = Thread.currentThread().getName() + ": executeCommon() called for GraphQL plugin.";
-    System.out.println(printMessage);
+    logger.debug("{}: executeCommon() called for GraphQL plugin.", Thread.currentThread().getName());
     
     // ...
 }

Make sure to add the necessary imports:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

And declare the logger at the class level:

private static final Logger logger = LoggerFactory.getLogger(GraphQLPlugin.class);
app/server/appsmith-plugins/arangoDBPlugin/src/main/java/com/external/plugins/ArangoDBPlugin.java (12)

88-89: Nitpick: Consider using a logger instead of System.out.println.

While the added logging statements provide useful information, it's generally recommended to use a logging framework like SLF4J instead of directly writing to System.out. This allows for better control over log levels and log output destinations.

-String printMessage = Thread.currentThread().getName() + ": execute() called for ArangoDB plugin.";
-System.out.println(printMessage);
+log.debug("execute() called for ArangoDB plugin.");

104-105: Nitpick: Use a logger instead of System.out.println.

As mentioned earlier, consider using a logging framework like SLF4J for consistency and better control over logging.

-System.out.println(Thread.currentThread().getName()
-        + ": got action execution result from ArangoDB plugin.");
+log.debug("Got action execution result from ArangoDB plugin.");

182-183: Nitpick: Use a logger instead of System.out.println.

For consistency and better control over logging, consider using a logging framework like SLF4J.

-String printMessage = Thread.currentThread().getName() + ": datasourceCreate() called for ArangoDB plugin.";
-System.out.println(printMessage);
+log.debug("datasourceCreate() called for ArangoDB plugin.");

185-186: Nitpick: Use a logger instead of System.out.println.

As mentioned earlier, consider using a logging framework like SLF4J for consistency and better control over logging.

-System.out.println(
-        Thread.currentThread().getName() + ": inside schdeuled thread from ArangoDB plugin.");
+log.debug("Inside scheduled thread from ArangoDB plugin.");

266-268: Nitpick: Use a logger instead of System.out.println.

For consistency and better control over logging, consider using a logging framework like SLF4J.

-String printMessage =
-        Thread.currentThread().getName() + ": datasourceDestroy() called for ArangoDB plugin.";
-System.out.println(printMessage);
+log.debug("datasourceDestroy() called for ArangoDB plugin.");

274-276: Nitpick: Use a logger instead of System.out.println.

As mentioned earlier, consider using a logging framework like SLF4J for consistency and better control over logging.

-String printMessage =
-        Thread.currentThread().getName() + ": validateDatasource() called for ArangoDB plugin.";
-System.out.println(printMessage);
+log.debug("validateDatasource() called for ArangoDB plugin.");

321-322: Nitpick: Use a logger instead of System.out.println.

For consistency and better control over logging, consider using a logging framework like SLF4J.

-String printMessage = Thread.currentThread().getName() + ": testDatasource() called for ArangoDB plugin.";
-System.out.println(printMessage);
+log.debug("testDatasource() called for ArangoDB plugin.");

328-329: Nitpick: Log the error using a logger instead of printing the stack trace.

Instead of printing the error stack trace directly to System.out, consider using a logger to log the error at an appropriate log level (e.g., error or warn).

-System.out.println("Error when testing ArangoDB datasource.");
-error.printStackTrace();
+log.error("Error when testing ArangoDB datasource.", error);

340-341: Nitpick: Use a logger instead of System.out.println.

As mentioned earlier, consider using a logging framework like SLF4J for consistency and better control over logging.

-String printMessage = Thread.currentThread().getName() + ": getStructure() called for ArangoDB plugin.";
-System.out.println(printMessage);
+log.debug("getStructure() called for ArangoDB plugin.");

361-362: Nitpick: Use a logger instead of System.out.println.

For consistency and better control over logging, consider using a logging framework like SLF4J.

-System.out.println(Thread.currentThread().getName()
-        + ": got collectionEntity result from ArangoDB plugin.");
+log.debug("Got collectionEntity result from ArangoDB plugin.");

388-389: Nitpick: Use a logger instead of System.out.println.

As mentioned earlier, consider using a logging framework like SLF4J for consistency and better control over logging.

-System.out.println(Thread.currentThread().getName()
-        + ": generating templates and structure in ArangoDB plugin.");
+log.debug("Generating templates and structure in ArangoDB plugin.");

406-408: Nitpick: Use a logger instead of System.out.println.

For consistency and better control over logging, consider using a logging framework like SLF4J.

-String printMessage = Thread.currentThread().getName()
-        + ": getEndpointIdentifierForRateLimit() called for ArangoDB plugin.";
-System.out.println(printMessage);
+log.debug("getEndpointIdentifierForRateLimit() called for ArangoDB plugin.");
app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/plugins/GoogleSheetsPlugin.java (5)

85-87: Consider using a proper logging framework instead of System.out.println().

While the added logging statement provides visibility into the execution flow, it's generally recommended to use a proper logging framework like SLF4J for production code. This allows for better control over log levels, log formatting, and log destinations.

-            String printMessage =
-                    Thread.currentThread().getName() + ": executeParameterized() called for GoogleSheets plugin.";
-            System.out.println(printMessage);
+            log.debug("executeParameterized() called for GoogleSheets plugin.");

146-148: Use a proper logging framework consistently for both regular logging and error handling.

Consider the following suggestions:

  1. For the added logging statement, use a proper logging framework like SLF4J instead of System.out.println().
-            String printMessage =
-                    Thread.currentThread().getName() + ": executeCommon() called for GoogleSheets plugin.";
-            System.out.println(printMessage);
+            log.debug("executeCommon() called for GoogleSheets plugin.");
  1. Revert the changes to the error handling logging and use the logging framework consistently. Instead of replacing log.debug() with System.out.println() and e.printStackTrace(), keep using the logging framework.
-                                    System.out.println("Received error on Google Sheets action execution");
-                                    e.printStackTrace();
+                                    log.debug("Received error on Google Sheets action execution", e);

Using a consistent logging approach makes it easier to manage and configure logging behavior across the application.

Also applies to: 258-259


327-328: Consider using a proper logging framework instead of System.out.println().

While the added logging statement provides visibility into the execution flow, it's generally recommended to use a proper logging framework like SLF4J for production code. This allows for better control over log levels, log formatting, and log destinations.

-            String printMessage = Thread.currentThread().getName() + ": trigger() called for GoogleSheets plugin.";
-            System.out.println(printMessage);
+            log.debug("trigger() called for GoogleSheets plugin.");

399-401: Consider using a proper logging framework instead of System.out.println().

While the added logging statement provides visibility into the execution flow, it's generally recommended to use a proper logging framework like SLF4J for production code. This allows for better control over log levels, log formatting, and log destinations.

-            String printMessage =
-                    Thread.currentThread().getName() + ": updateCrudTemplateFormData() called for GoogleSheets plugin.";
-            System.out.println(printMessage);
+            log.debug("updateCrudTemplateFormData() called for GoogleSheets plugin.");

415-417: Consider using a proper logging framework instead of System.out.println().

While the added logging statement provides visibility into the execution flow, it's generally recommended to use a proper logging framework like SLF4J for production code. This allows for better control over log levels, log formatting, and log destinations.

-            String printMessage =
-                    Thread.currentThread().getName() + ": getDatasourceMetadata() called for GoogleSheets plugin.";
-            System.out.println(printMessage);
+            log.debug("getDatasourceMetadata() called for GoogleSheets plugin.");
app/server/appsmith-plugins/oraclePlugin/src/main/java/com/external/plugins/OraclePlugin.java (6)

97-98: Consider using a logging framework instead of System.out.println.

While the added print statements provide insights into the execution flow, it's generally recommended to use a proper logging framework (e.g., SLF4J) instead of System.out.println. A logging framework offers better control over log levels, formatting, and destinations.

Consider replacing the System.out.println statements with appropriate logging framework methods. For example:

- String printMessage = Thread.currentThread().getName() + ": datasourceCreate() called for Oracle plugin.";
- System.out.println(printMessage);
+ log.debug("datasourceCreate() called for Oracle plugin.");

122-123: Consider using a logging framework instead of System.out.println.

As mentioned earlier, it's recommended to use a proper logging framework instead of System.out.println for better control and maintainability.

Consider replacing the System.out.println statements with appropriate logging framework methods. For example:

- String printMessage = Thread.currentThread().getName() + ": validateDatasource() called for Oracle plugin.";
- System.out.println(printMessage);
+ log.debug("validateDatasource() called for Oracle plugin.");

142-145: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a proper logging framework for better control and maintainability.

Consider replacing the System.out.println statements with appropriate logging framework methods. For example:

- String printMessage =
-         Thread.currentThread().getName() + ": executeParameterized() called for Oracle plugin.";
- System.out.println(printMessage);
+ log.debug("executeParameterized() called for Oracle plugin.");

204-205: Consider using a logging framework instead of System.out.println.

As mentioned earlier, it's recommended to use a proper logging framework for better control and maintainability. This applies to both the method entry logging and exception logging.

Consider replacing the System.out.println statements with appropriate logging framework methods. For example:

- String printMessage = Thread.currentThread().getName() + ": executeCommon() called for Oracle plugin.";
- System.out.println(printMessage);
+ log.debug("executeCommon() called for Oracle plugin.");

// ...

- System.out.println(
-         "Exception Occurred while getting connection from pool" + e.getMessage());
- e.printStackTrace(System.out);
+ log.error("Exception occurred while getting connection from pool", e);

// ...

- System.out.println(Thread.currentThread().getName()
-         + ": In the OraclePlugin, got action execution error");
- System.out.println(e.getMessage());
+ log.error("Error occurred during action execution in OraclePlugin", e);

Also applies to: 234-235, 288-290


339-340: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a proper logging framework for better control and maintainability.

Consider replacing the System.out.println statements with appropriate logging framework methods. For example:

- String printMessage = Thread.currentThread().getName() + ": getStructure() called for Oracle plugin.";
- System.out.println(printMessage);
+ log.debug("getStructure() called for Oracle plugin.");

449-451: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a proper logging framework for better control and maintainability.

Consider replacing the System.out.println statements with appropriate logging framework methods. For example:

- String printMessage = Thread.currentThread().getName()
-         + ": getEndpointIdentifierForRateLimit() called for Oracle plugin.";
- System.out.println(printMessage);
+ log.debug("getEndpointIdentifierForRateLimit() called for Oracle plugin.");
app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java (5)

138-140: Consider using a proper logging framework.

While the added System.out.println statements can be helpful for debugging, it's generally recommended to use a proper logging framework (e.g., SLF4J) instead of directly writing to the console output. This allows for better control over log levels, log formatting, and log destinations.

Consider replacing the System.out.println statements with appropriate logging statements using a logging framework.


189-190: Consider using a proper logging framework.

As mentioned in the previous comment, it's recommended to use a proper logging framework instead of System.out.println statements for better control over logging.

Please consider replacing the System.out.println statements with appropriate logging statements using a logging framework.

Also applies to: 201-202


Line range hint 230-250: Revert the changes and throw the StaleConnectionException directly.

Instead of replacing the exception throwing code with System.out.println statements and throwing the exception separately based on the condition, it's recommended to throw the StaleConnectionException directly with appropriate error messages. This makes the code more concise and readable.

Revert the changes and update the code to throw the StaleConnectionException directly with appropriate error messages, like this:

if (sqlConnectionFromPool == null) {
    throw new StaleConnectionException(CONNECTION_NULL_ERROR_MSG);
} else if (sqlConnectionFromPool.isClosed()) {
    throw new StaleConnectionException(CONNECTION_CLOSED_ERROR_MSG);
} else if (!sqlConnectionFromPool.isValid(VALIDITY_CHECK_TIMEOUT)) {
    throw new StaleConnectionException(CONNECTION_INVALID_ERROR_MSG);
}

309-313: Good usage of Stopwatch for performance monitoring, but use a proper logging framework.

Measuring the execution time of the objectMapper.valueToTree method using a Stopwatch is a good practice for performance monitoring and optimization. It can help identify performance bottlenecks and guide optimization efforts.

However, as mentioned in previous comments, it's recommended to use a proper logging framework instead of System.out.println statements for logging. This allows for better control over log levels, formatting, and destinations.

Consider replacing the System.out.println statements with appropriate logging statements using a logging framework while keeping the Stopwatch usage intact.


362-365: Consider using a proper logging framework.

As mentioned in previous comments, it's recommended to use a proper logging framework instead of System.out.println statements for better control over logging.

Please consider replacing the System.out.println statements with appropriate logging statements using a logging framework in the datasourceCreate, validateDatasource, and getStructure methods.

Also applies to: 380-381, 425-426

app/server/appsmith-plugins/redshiftPlugin/src/main/java/com/external/plugins/RedshiftPlugin.java (2)

198-199: Good effort in adding tracing logs, but use a logging framework.

It's a good practice to add logging statements to trace the execution flow, as it can greatly help in debugging and monitoring. However, as mentioned earlier, it's better to use a logging framework instead of System.out.println.

Consider replacing the print statement with an appropriate logging statement, e.g.:

log.debug(Thread.currentThread().getName() + ": execute() called for Redshift plugin.");

336-338: Good effort in adding connection pool monitoring logs, but use a logging framework.

It's a good practice to add logging statements to monitor the connection pool status, as it can help in debugging and performance tuning. However, as mentioned earlier, it's better to use a logging framework instead of System.out.println.

Consider replacing the print statements with appropriate logging statements, e.g.:

log.debug(Thread.currentThread().getName() + (isFetchingStructure ? " Before fetching Redshift db structure." : " Before executing Redshift query.") + " Hikari Pool stats: active - " + activeConnections + ", idle - " + idleConnections + ", awaiting - " + threadsAwaitingConnection + ", total - " + totalConnections);

Also applies to: 344-354

app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java (5)

186-188: Consider using a logging framework instead of System.out.println.

While the added logging statement helps in debugging, it's a good practice to use a proper logging framework (e.g., SLF4J) instead of directly using System.out.println. This allows for better control over log levels, formatting, and destinations.

Replace the System.out.println statement with a logger:

-            String printMessage =
-                    Thread.currentThread().getName() + ": executeParameterized() called for MySQL plugin.";
-            System.out.println(printMessage);
+            log.debug("executeParameterized() called for MySQL plugin.");

247-249: Consider using a logging framework instead of System.out.println.

As mentioned earlier, it's a good practice to use a proper logging framework (e.g., SLF4J) instead of directly using System.out.println. This allows for better control over log levels, formatting, and destinations.

Replace the System.out.println statement with a logger:

-            String printMessage =
-                    Thread.currentThread().getName() + ": getSchemaPreviewActionConfig() called for MySQL plugin.";
-            System.out.println(printMessage);
+            log.debug("getSchemaPreviewActionConfig() called for MySQL plugin.");

265-267: Consider using a logging framework instead of System.out.println.

As mentioned earlier, it's a good practice to use a proper logging framework (e.g., SLF4J) instead of directly using System.out.println. This allows for better control over log levels, formatting, and destinations.

Replace the System.out.println statement with a logger:

-            String printMessage =
-                    Thread.currentThread().getName() + ": getEndpointIdentifierForRateLimit() called for MySQL plugin.";
-            System.out.println(printMessage);
+            log.debug("getEndpointIdentifierForRateLimit() called for MySQL plugin.");

298-299: Consider using a logging framework and good job adding the Stopwatch instance.

  1. As mentioned earlier, it's a good practice to use a proper logging framework (e.g., SLF4J) instead of directly using System.out.println. This allows for better control over log levels, formatting, and destinations.

Replace the System.out.println statement with a logger:

-            String printMessage = Thread.currentThread().getName() + ": executeCommon() called for MySQL plugin.";
-            System.out.println(printMessage);
+            log.debug("executeCommon() called for MySQL plugin.");
  1. The addition of the Stopwatch instance to track the time taken for the objectMapper.valueToTree operation is a good idea. It can help identify potential performance bottlenecks and optimize the code if needed.

Also applies to: 400-406


519-520: Consider using a logging framework instead of System.out.println.

As mentioned earlier, it's a good practice to use a proper logging framework (e.g., SLF4J) instead of directly using System.out.println. This allows for better control over log levels, formatting, and destinations.

Replace the System.out.println statements with a logger in the following methods:

  • testDatasource
  • datasourceCreate
  • datasourceDestroy
  • validateDatasource
  • getStructure

For example:

-            String printMessage = Thread.currentThread().getName() + ": testDatasource() called for MySQL plugin.";
-            System.out.println(printMessage);
+            log.debug("testDatasource() called for MySQL plugin.");

Also applies to: 673-674, 691-692, 707-707, 725-726, 736-737, 744-745

app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java (7)

247-249: Consider using a logger instead of System.out.println.

Adding the logging statement is helpful for debugging. However, it's generally recommended to use a logging framework like SLF4J instead of directly using System.out.println. This allows for better control over log levels and log output destinations.

You can replace the System.out.println with an SLF4J logger:

-            String printMessage =
-                    Thread.currentThread().getName() + ": executeParameterized() called for Mongo plugin.";
-            System.out.println(printMessage);
+            log.debug("{}: executeParameterized() called for Mongo plugin.", Thread.currentThread().getName());

311-312: Use a logger instead of System.out.println.

As mentioned earlier, it's better to use a logging framework like SLF4J for logging statements. Please replace the System.out.println with an SLF4J logger.

-            String printMessage = Thread.currentThread().getName() + ": executeCommon() called for Mongo plugin.";
-            System.out.println(printMessage);
+            log.debug("{}: executeCommon() called for Mongo plugin.", Thread.currentThread().getName());

314-314: Use a logger instead of System.out.println.

Please use a logging framework like SLF4J for logging statements instead of System.out.println.

-                System.out.println("Encountered null connection in MongoDB plugin. Reporting back.");
+                log.error("Encountered null connection in MongoDB plugin. Reporting back.");

322-322: Use a logger instead of System.out.println.

As mentioned before, please use a logging framework like SLF4J for logging statements instead of System.out.println.

-                System.out.println(Thread.currentThread().getName() + ": mongoClient.getDatabase from Mongo plugin.");
+                log.debug("{}: mongoClient.getDatabase from Mongo plugin.", Thread.currentThread().getName());

496-497: Use a logger instead of System.out.println.

Please use a logging framework like SLF4J for logging statements instead of System.out.println.

-            System.out.println(
-                    "The mongo connection seems to have been invalidated or doesn't exist anymore");
+            log.error("The mongo connection seems to have been invalidated or doesn't exist anymore");

512-513: Use a logger instead of System.out.println.

As mentioned before, please use a logging framework like SLF4J for logging statements instead of System.out.println.

-        System.out.println(Thread.currentThread().getName()
-                + ": building actionExecutionResult from Mongo plugin.");
+        log.debug("{}: building actionExecutionResult from Mongo plugin.", Thread.currentThread().getName());

541-542: Use a logger instead of System.out.println.

Please use a logging framework like SLF4J for logging statements instead of System.out.println.

-            String printMessage = Thread.currentThread().getName() + ": sanitizeReplacement() called for Mongo plugin.";
-            System.out.println(printMessage);
+            log.debug("{}: sanitizeReplacement() called for Mongo plugin.", Thread.currentThread().getName());
app/server/appsmith-plugins/amazons3Plugin/src/main/java/com/external/plugins/AmazonS3Plugin.java (12)

419-421: Consider using a logging framework instead of System.out.println.

It's a good practice to use a logging framework like SLF4J or Log4j for logging in production code. This allows for more controlled and configurable logging compared to using System.out.println directly.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(printMessage);
+ log.debug(printMessage);

470-471: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comment, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(printMessage);
+ log.debug(printMessage);

547-548: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(Thread.currentThread().getName() + ": LIST action called for AmazonS3 plugin.");
+ log.debug("LIST action called for AmazonS3 plugin.");

647-648: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(Thread.currentThread().getName() + ": UPLOAD_FILE_FROM_BODY action called for AmazonS3 plugin.");
+ log.debug("UPLOAD_FILE_FROM_BODY action called for AmazonS3 plugin.");

700-701: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(Thread.currentThread().getName() + ": UPLOAD_MULTIPLE_FILES_FROM_BODY action called for AmazonS3 plugin.");
+ log.debug("UPLOAD_MULTIPLE_FILES_FROM_BODY action called for AmazonS3 plugin.");

754-755: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(Thread.currentThread().getName() + ": READ_FILE action called for AmazonS3 plugin.");
+ log.debug("READ_FILE action called for AmazonS3 plugin.");

773-774: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(Thread.currentThread().getName() + ": DELETE_FILE action called for AmazonS3 plugin.");
+ log.debug("DELETE_FILE action called for AmazonS3 plugin.");

786-787: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(Thread.currentThread().getName() + ": DELETE_MULTIPLE_FILES action called for AmazonS3 plugin.");
+ log.debug("DELETE_MULTIPLE_FILES action called for AmazonS3 plugin.");

826-826: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println("In the S3 Plugin, got action execution result");
+ log.debug("Got action execution result");

845-846: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(Thread.currentThread().getName() + ": Setting the actionExecutionResult for AmazonS3 plugin.");
+ log.debug("Setting the actionExecutionResult for AmazonS3 plugin.");

895-896: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(printMessage);
+ log.debug(printMessage);

924-926: Consider using a logging framework instead of System.out.println.

As mentioned in the previous comments, it's recommended to use a logging framework for more controlled and configurable logging in production code.

Consider replacing the System.out.println statement with a logger from a logging framework. For example, using SLF4J:

- System.out.println(printMessage);
+ log.debug(printMessage);
app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (1)

Line range hint 363-608: Consider using a logging framework and a performance monitoring framework/library.

The changes in the executeCommon method involve adding several logging statements using System.out.println and introducing Stopwatch to measure execution times for specific operations.

While the additional logging can provide valuable information for debugging and monitoring, it is recommended to use a logging framework instead of System.out.println for better maintainability, flexibility, and performance. A logging framework allows you to control log levels, format log messages, and direct the output to different destinations.

Similarly, while the introduction of Stopwatch is a good practice to measure and log the execution times of critical operations, it would be better to use a more robust and standardized performance monitoring framework or library. Such frameworks provide consistent and detailed performance tracking, allowing you to monitor and analyze the performance of your application more effectively.

Consider the following suggestions:

  1. Replace the System.out.println statements with calls to a logging framework (e.g., SLF4J, Log4j) throughout the codebase for improved logging practices.
  2. Investigate and integrate a performance monitoring framework or library (e.g., Micrometer, Dropwizard Metrics) to track and measure the performance of critical operations consistently.

By adopting these practices, you can enhance the maintainability, flexibility, and observability of your codebase.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f02b448 and cb10d1c.

Files selected for processing (25)
  • app/server/appsmith-plugins/amazons3Plugin/src/main/java/com/external/plugins/AmazonS3Plugin.java (19 hunks)
  • app/server/appsmith-plugins/amazons3Plugin/src/main/java/com/external/utils/DatasourceUtils.java (1 hunks)
  • app/server/appsmith-plugins/anthropicPlugin/src/main/java/com/external/plugins/AnthropicPlugin.java (4 hunks)
  • app/server/appsmith-plugins/appsmithAiPlugin/src/main/java/com/external/plugins/AppsmithAiPlugin.java (5 hunks)
  • app/server/appsmith-plugins/arangoDBPlugin/src/main/java/com/external/plugins/ArangoDBPlugin.java (9 hunks)
  • app/server/appsmith-plugins/awsLambdaPlugin/src/main/java/com/external/plugins/AwsLambdaPlugin.java (5 hunks)
  • app/server/appsmith-plugins/databricksPlugin/src/main/java/com/external/plugins/DatabricksPlugin.java (6 hunks)
  • app/server/appsmith-plugins/dynamoPlugin/src/main/java/com/external/plugins/DynamoPlugin.java (8 hunks)
  • app/server/appsmith-plugins/elasticSearchPlugin/src/main/java/com/external/plugins/ElasticSearchPlugin.java (7 hunks)
  • app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java (13 hunks)
  • app/server/appsmith-plugins/googleAiPlugin/src/main/java/com/external/plugins/GoogleAiPlugin.java (3 hunks)
  • app/server/appsmith-plugins/googleSheetsPlugin/src/main/java/com/external/plugins/GoogleSheetsPlugin.java (6 hunks)
  • app/server/appsmith-plugins/graphqlPlugin/src/main/java/com/external/plugins/GraphQLPlugin.java (2 hunks)
  • app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java (18 hunks)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java (11 hunks)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java (15 hunks)
  • app/server/appsmith-plugins/openAiPlugin/src/main/java/com/external/plugins/OpenAiPlugin.java (4 hunks)
  • app/server/appsmith-plugins/oraclePlugin/src/main/java/com/external/plugins/OraclePlugin.java (10 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (20 hunks)
  • app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java (6 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/java/com/external/plugins/RedshiftPlugin.java (11 hunks)
  • app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java (3 hunks)
  • app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java (4 hunks)
  • app/server/appsmith-plugins/smtpPlugin/src/main/java/com/external/plugins/SmtpPlugin.java (8 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/java/com/external/plugins/SnowflakePlugin.java (11 hunks)
Files skipped from review due to trivial changes (2)
  • app/server/appsmith-plugins/amazons3Plugin/src/main/java/com/external/utils/DatasourceUtils.java
  • app/server/appsmith-plugins/googleAiPlugin/src/main/java/com/external/plugins/GoogleAiPlugin.java
Additional comments not posted (71)
app/server/appsmith-plugins/awsLambdaPlugin/src/main/java/com/external/plugins/AwsLambdaPlugin.java (6)

63-64: Good job adding a log message to track the execution flow!

Including the current thread's name in the log message is a helpful practice for monitoring and debugging, especially in multi-threaded environments. This log statement provides visibility into when the execute method is invoked without altering its functionality.


69-70: Excellent addition of a log message to track the creation of the action execution result!

Printing the current thread's name along with a descriptive message helps in understanding the execution flow and can be beneficial for monitoring and debugging purposes, particularly in multi-threaded scenarios. This log statement enhances traceability without modifying the behavior of the code.


97-98: Great work adding a log message to track the invocation of the trigger method!

Incorporating the current thread's name in the log message is a valuable practice for monitoring and debugging, especially in multi-threaded contexts. This log statement provides insight into when the trigger method is called without modifying its behavior.


152-154: Excellent job adding a log message to track the invocation of the datasourceCreate method!

Including the current thread's name in the log message is a commendable practice for monitoring and debugging purposes, particularly in multi-threaded environments. This log statement provides visibility into when the datasourceCreate method is called without altering its functionality.


190-191: Well done adding a log message to track the invocation of the testDatasource method!

Incorporating the current thread's name in the log message is a valuable practice for monitoring and debugging, especially in multi-threaded contexts. This log statement provides insight into when the testDatasource method is called without modifying its behavior.


221-223: Excellent addition of a log message to track the invocation of the validateDatasource method!

Including the current thread's name in the log message is a commendable practice for monitoring and debugging purposes, particularly in multi-threaded environments. This log statement provides visibility into when the validateDatasource method is called without altering its functionality.

app/server/appsmith-plugins/appsmithAiPlugin/src/main/java/com/external/plugins/AppsmithAiPlugin.java (7)

68-70: Great job adding the logging statement to track the execution flow!

The added code segment enhances observability by printing a message to the console when the datasourceCreate method is called, along with the current thread name. This information can be valuable for debugging and understanding the runtime behavior of the plugin.

Keep up the good work in improving the plugin's logging capabilities!


84-85: Excellent addition of the logging statement in the trigger method!

The introduced code segment enhances traceability by printing a message to the console when the trigger method is invoked, along with the current thread name. This information can be instrumental in understanding the runtime behavior and identifying potential issues related to multithreading.

Your efforts in improving the plugin's logging capabilities are commendable. Keep up the great work!


151-153: Fantastic work adding the logging statement in the executeParameterized method!

The introduced code segment enhances observability by printing a message to the console when the executeParameterized method is called, along with the current thread name. This information can be valuable for debugging and understanding the runtime behavior of the plugin, especially in scenarios involving parameterized execution.

Your commitment to improving the plugin's logging capabilities is highly appreciated. Keep up the excellent work!


173-174: Excellent addition of the logging statement in the executeCommon method!

The introduced code segment enhances traceability by printing a message to the console when the executeCommon method is invoked, along with the current thread name. This information can be instrumental in understanding the runtime behavior and identifying potential issues related to the common execution path.

Your efforts in improving the plugin's logging capabilities are commendable. Keep up the great work!


212-214: Great job adding the logging statement in the validateDatasource method!

The introduced code segment enhances observability by printing a message to the console when the validateDatasource method is called, along with the current thread name. This information can be valuable for debugging and understanding the runtime behavior of the plugin during datasource validation.

Your commitment to improving the plugin's logging capabilities is highly appreciated. Keep up the excellent work!


220-221: Excellent addition of the logging statement in the preSaveHook method!

The introduced code segment enhances traceability by printing a message to the console when the preSaveHook method is invoked, along with the current thread name. This information can be instrumental in understanding the runtime behavior and identifying potential issues related to the pre-save hook execution.

Your efforts in improving the plugin's logging capabilities are commendable. Keep up the great work!


229-230: Fantastic work adding the logging statement in the preDeleteHook method!

The introduced code segment enhances observability by printing a message to the console when the preDeleteHook method is called, along with the current thread name. This information can be valuable for debugging and understanding the runtime behavior of the plugin during the pre-delete hook execution.

Your commitment to improving the plugin's logging capabilities is highly appreciated. Keep up the excellent work!

app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java (1)

6-6: Import statement looks good.

The import statement for the Stopwatch class is added correctly.

app/server/appsmith-plugins/smtpPlugin/src/main/java/com/external/plugins/SmtpPlugin.java (5)

169-169: Use a logging framework and provide a more informative log message.

As mentioned earlier, it's better to use a logging framework like SLF4J instead of System.out.println.

Consider including more details in the log message, such as the recipient, subject, or any other relevant information about the email being sent.

For example:

log.info("Sending email to '{}' with subject '{}'", toAddress, subject);

177-177: Use a logging framework and include more details in the success message.

As previously mentioned, please use a logging framework like SLF4J for consistency and better control over log levels.

To make the success message more informative, consider including details like the recipient, subject, or any other relevant information about the sent email.

For example:

log.info("Email sent successfully to '{}' with subject '{}'", toAddress, subject);

203-204: Use a logging framework and provide a more descriptive log message.

As mentioned in previous comments, it's recommended to use a logging framework like SLF4J instead of System.out.println.

To provide more context about the datasource creation, consider including details like the datasource name or configuration in the log message.

For example:

log.debug("Creating datasource '{}' with configuration: {}", datasourceConfiguration.getName(), datasourceConfiguration);

231-232: Use a logging framework and provide a more descriptive log message.

As previously suggested, please use a logging framework like SLF4J for logging instead of System.out.println.

To provide more context about the datasource destruction, consider including details like the datasource name or any other relevant information in the log message.

For example:

log.debug("Destroying datasource '{}'", datasourceConfiguration.getName());

244-245: Use a logging framework, provide more descriptive log messages, and properly log exceptions.

As mentioned in previous comments, it's recommended to use a logging framework like SLF4J instead of System.out.println for logging.

For the log messages in the validateDatasource(), testDatasource(), and getEndpointIdentifierForRateLimit() methods, consider providing more context about the respective operations. Include details like the datasource configuration or any other relevant information.

For example:

log.debug("Validating datasource configuration: {}", datasourceConfiguration);
log.debug("Testing datasource connection for configuration: {}", datasourceConfiguration);
log.debug("Getting endpoint identifier for rate limit for datasource: {}", datasourceConfiguration);

In the testDatasource() method, instead of printing the exception message using System.out.println, log the exception using the logging framework.

For example:

log.error("Error occurred while testing datasource connection", e);

This will provide a proper stack trace and allow for better exception handling.

Also applies to: 268-269, 283-283, 293-295

app/server/appsmith-plugins/openAiPlugin/src/main/java/com/external/plugins/OpenAiPlugin.java (5)

78-80: Good job adding a logging statement to track the thread and method execution.

The added print statement provides useful information for debugging and monitoring purposes without affecting the method's functionality. Keep up the great work!


98-99: Excellent addition of a logging statement to track the thread and method execution.

The print statement you added will be very helpful for tracing the execution flow and identifying potential issues. It's a valuable addition that enhances the code's maintainability. Well done!


208-209: Great job adding a logging statement to track the thread and method execution.

The print statement you introduced provides valuable information for understanding the execution flow and facilitates debugging. It's a thoughtful addition that improves the code's observability. Keep up the excellent work!


217-218: Excellent work adding a logging statement to track the thread and method execution.

The print statement you added is a great way to provide insights into the execution flow and assist with debugging efforts. It enhances the code's maintainability without impacting its behavior. Well done!


288-289: Great addition of a logging statement to track the thread and method execution.

The print statement you introduced provides valuable information for tracing the execution flow and identifying potential issues. It's a thoughtful addition that improves the code's observability without affecting its core functionality. Keep up the fantastic work!

app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java (8)

71-72: Logging statement looks good!

Adding a logging statement to print the current thread name and a message when the execute method is called can be helpful for tracing execution in a multi-threaded environment. This change is approved.


124-126: Logging statement looks good!

Adding a logging statement to print the current thread name and a message when the action execution result is obtained can be helpful for tracing execution in a multi-threaded environment. This change is approved.


259-260: Logging statement looks good!

Adding a logging statement to print the current thread name and a message when the datasourceCreate method is called can be helpful for tracing execution in a multi-threaded environment. This change is approved.


267-267: Logging statement looks good!

Adding a logging statement to print the current thread name and a message when the Jedis pool is created can be helpful for tracing execution in a multi-threaded environment. This change is approved.


275-276: Logging statement looks good!

Adding a logging statement to print the current thread name and a message when the datasourceDestroy method is called can be helpful for tracing execution in a multi-threaded environment. This change is approved.


295-296: Logging statement looks good!

Adding a logging statement to print the current thread name and a message when the validateDatasource method is called can be helpful for tracing execution in a multi-threaded environment. This change is approved.


313-315: Logging statement looks good!

Adding a logging statement to print the current thread name and a message when the getEndpointIdentifierForRateLimit method is called can be helpful for tracing execution in a multi-threaded environment. This change is approved.


381-382: Logging statement looks good!

Adding a logging statement to print the current thread name and a message when the testDatasource method is called can be helpful for tracing execution in a multi-threaded environment. This change is approved.

app/server/appsmith-plugins/databricksPlugin/src/main/java/com/external/plugins/DatabricksPlugin.java (4)

82-83: Good job adding logging statements to improve visibility!

The logging statements you've added in the execute method will be very helpful for monitoring the execution flow and diagnosing issues, particularly in multi-threaded scenarios. They provide valuable context about which thread is executing the method and when key actions like creating the action execution result are performed.

Keep up the great work in enhancing the logging capabilities of the plugin!

Also applies to: 90-91


186-188: Excellent addition of a logging statement in the datasourceCreate method!

The logging statement you've introduced at the beginning of the datasourceCreate method is a valuable addition. It clearly indicates when the method is called and which thread is executing it. This information can be incredibly useful for tracing the flow of execution and identifying potential issues related to datasource creation.

Your efforts to enhance the logging capabilities of the plugin are commendable. Well done!


304-306: Great job adding logging statements to the datasourceDestroy method!

The logging statements you've included at the beginning of the datasourceDestroy method are a valuable addition. They clearly indicate when the method is invoked and which thread is responsible for executing it. This information can be extremely helpful for monitoring the datasource destruction process and identifying any related issues.

Your efforts to improve the logging capabilities of the plugin are greatly appreciated. Keep up the excellent work!


325-326: Fantastic work adding logging statements to the getStructure method!

The logging statements you've introduced in the getStructure method are a great addition. They clearly indicate when the method is called and which thread is executing it. Furthermore, the logging statement at the beginning of the fromSupplier block provides valuable information about when the datasource structure is being fetched.

These logging enhancements will be extremely useful for monitoring the process of retrieving the datasource structure and identifying any related issues. Your efforts to improve the logging capabilities of the plugin are highly appreciated.

Excellent job on enhancing the code with these informative logging statements!

Also applies to: 328-329

app/server/appsmith-plugins/dynamoPlugin/src/main/java/com/external/plugins/DynamoPlugin.java (7)

94-95: Good job adding the log statement to track the thread execution!

The log message will help in debugging and understanding the flow of execution in a multi-threaded environment. Keep up the great work in improving the observability of the code.


167-169: Excellent work adding the log statement to track the thread execution!

The log message will aid in tracing the execution flow and identifying any potential issues in a multi-threaded scenario. Your efforts in enhancing the observability of the codebase are commendable.


191-199: Fantastic work adding the log statements to track the thread execution and action result creation!

The log messages will greatly assist in understanding the execution flow and identifying any bottlenecks or issues in a multi-threaded context. Your dedication to improving the observability and debuggability of the code is highly appreciated. Keep up the excellent work!


289-293: Wonderful job adding the log statements to track the thread execution and DynamoDbClient creation!

The log messages will significantly help in tracing the execution flow and identifying any issues or performance bottlenecks in a multi-threaded scenario. Your commitment to enhancing the observability and maintainability of the codebase is truly appreciated. Your efforts will make debugging and understanding the code much easier for the entire team. Well done!


329-330: Excellent work adding the log statement to track the thread execution in the validateDatasource method!

The log message will aid in understanding the execution flow and identifying any potential issues or bottlenecks in a multi-threaded context. Your efforts in improving the observability and debuggability of the code are highly valued. Keep up the great work in making the codebase more maintainable and easier to understand!


355-356: Great job adding the log statement to track the thread execution in the testDatasource method!

The log message will greatly help in tracing the execution flow and identifying any issues or performance bottlenecks in a multi-threaded scenario. Your dedication to enhancing the observability and maintainability of the codebase is commendable. Your efforts will make debugging and understanding the code much easier for the entire team. Well done!


370-374: Fantastic work adding the log statements to track the thread execution and datasource structure creation in the getStructure method!

The log messages will significantly aid in understanding the execution flow and identifying any potential issues or performance bottlenecks in a multi-threaded context. Your commitment to improving the observability and debuggability of the code is highly appreciated. Your efforts will make tracing and understanding the code much easier for the entire team. Keep up the excellent work in enhancing the maintainability of the codebase!

app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java (1)

11-11: Import statement looks good.

The import statement for com.appsmith.external.helpers.Stopwatch is correctly added to use the Stopwatch utility in the code.

app/server/appsmith-plugins/redshiftPlugin/src/main/java/com/external/plugins/RedshiftPlugin.java (5)

150-150: Use a logging framework instead of print statements.

As mentioned in the previous comment, it's recommended to use a logging framework instead of System.out.println statements.


276-277: Use a logging framework for error logging.

As mentioned in the previous comments, it's recommended to use a logging framework instead of System.out.println statements for error logging.

Also applies to: 285-286


293-294: Use a logging framework for error logging.

As mentioned in the previous comments, it's recommended to use a logging framework instead of System.out.println statements for error logging.


302-303: Use a logging framework for tracing logs.

As mentioned earlier, it's a good practice to add logging statements to trace the execution flow. However, it's better to use a logging framework instead of System.out.println.


375-376: Use a logging framework for all the tracing and error logs.

It's good to see the effort put into adding various tracing logs to monitor the execution flow across different methods. However, as mentioned in the previous comments, it's recommended to use a logging framework instead of System.out.println for all these logs, including the error log in the getStructure method.

Also applies to: 387-387, 395-397, 405-407, 452-454, 628-629, 668-668, 700-701

app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java (1)

12-12: Good job adding the necessary import statement.

The import statement for com.appsmith.external.helpers.Stopwatch is required for using the Stopwatch class later in the code.

app/server/appsmith-plugins/firestorePlugin/src/main/java/com/external/plugins/FirestorePlugin.java (12)

141-143: Good job adding a debug message to trace the execution flow!

Including the current thread name in the message is a helpful practice for identifying which thread is executing the code, especially in multi-threaded environments. This can aid in debugging and understanding the program's behavior.


250-251: Nice work adding a debug message to track the invocation of objectMapper.readValue!

Including the current thread name in the message is a good practice for identifying which thread is executing the code, especially in multi-threaded environments. This can help in debugging and understanding the program's behavior.


323-324: Great job adding a debug message to trace the setting of the request in the action execution result!

Including the current thread name in the message is a helpful practice for identifying which thread is executing the code, especially in multi-threaded environments. This can aid in debugging and understanding the program's behavior.


511-513: Excellent work adding a debug message to trace the execution of the handleDocumentLevelMethod!

Including the current thread name in the message is a good practice for identifying which thread is executing the code, especially in multi-threaded environments. This can help in debugging and understanding the program's behavior.


606-608: Well done adding a debug message to trace the execution of the handleCollectionLevelMethod!

Including the current thread name in the message is a helpful practice for identifying which thread is executing the code, especially in multi-threaded environments. This can aid in debugging and understanding the program's behavior.


904-906: Excellent job adding a debug message to trace the execution of the datasourceCreate method!

Including the current thread name in the message is a good practice for identifying which thread is executing the code, especially in multi-threaded environments. This can help in debugging and understanding the program's behavior.


922-923: Great work adding a debug message to trace the instantiation of the GoogleCredentials object!

Including the current thread name in the message is a helpful practice for identifying which thread is executing the code, especially in multi-threaded environments. This can aid in debugging and understanding the program's behavior.


954-955: Excellent job adding a debug message to trace the execution of the testDatasource method!

Including the current thread name in the message is a good practice for identifying which thread is executing the code, especially in multi-threaded environments. This can help in debugging and understanding the program's behavior.


960-960: Good job adding a debug message to log invalid datasource configurations!

Printing the error message from the caught exception provides valuable context about the cause of the invalid datasource configuration. This information can be helpful for debugging and identifying issues related to the datasource setup.


982-984: Great work adding a debug message to trace the execution of the validateDatasource method!

Including the current thread name in the message is a helpful practice for identifying which thread is executing the code, especially in multi-threaded environments. This can aid in debugging and understanding the program's behavior.


1012-1013: Excellent job adding a debug message to trace the execution of the getStructure method!

Including the current thread name in the message is a good practice for identifying which thread is executing the code, especially in multi-threaded environments. This can help in debugging and understanding the program's behavior.


1015-1016: Well done adding a debug message to track the invocation of connection.listCollections!

Including the current thread name in the message is a helpful practice for identifying which thread is executing the code, especially in multi-threaded environments. This can aid in debugging and understanding the program's behavior.

app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java (8)

15-15: Looks good!

The new import statement for the Stopwatch class is fine. It will likely be used for measuring execution time.


389-396: Good addition for performance monitoring!

Using a Stopwatch to measure the time taken by the objectMapper.readTree operation for the VALUE field is a good practice for identifying performance bottlenecks. The code change looks fine.


404-411: Good addition for performance monitoring!

Using a Stopwatch to measure the time taken by the objectMapper.readTree operation for the CURSOR field is a good practice for identifying performance bottlenecks. The code change looks fine.


420-425: Good addition for performance monitoring!

Using a Stopwatch to measure the time taken by the objectMapper.readTree operation for the N field is a good practice for identifying performance bottlenecks. The code change looks fine.


434-441: Good addition for performance monitoring!

Using a Stopwatch to measure the time taken by the objectMapper.readTree operation for the N_MODIFIED field is a good practice for identifying performance bottlenecks. The code change looks fine.


451-469: Good addition for performance monitoring!

Using multiple Stopwatch instances to measure the time taken by different objectMapper operations for the VALUES field is a good practice for identifying performance bottlenecks. The code change looks fine.


480-484: Good addition for performance monitoring!

Using a Stopwatch to measure the time taken by the objectMapper.readTree operation for setting the result headers is a good practice for identifying performance bottlenecks. The code change looks fine.


634-639: Good addition for performance monitoring!

Using a Stopwatch to measure the time taken by the objectMapper.writeValueAsString operation is a good practice for identifying performance bottlenecks. The code change looks fine.

app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (1)

13-13: Looks good!

The import statement for the Stopwatch class is a valid addition.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cb10d1c and c63aa4c.

Files selected for processing (7)
  • app/client/packages/eslint-plugin/package.json (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/Stopwatch.java (1 hunks)
  • app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java (18 hunks)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java (11 hunks)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java (15 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (20 hunks)
  • app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java (4 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/packages/eslint-plugin/package.json
Files skipped from review as they are similar to previous changes (5)
  • app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java
  • app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java
  • app/server/appsmith-plugins/mysqlPlugin/src/main/java/com/external/plugins/MySqlPlugin.java
  • app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
  • app/server/appsmith-plugins/saasPlugin/src/main/java/com/external/plugins/SaasPlugin.java
Additional comments not posted (1)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/Stopwatch.java (1)

28-38: Consider alternatives to System.out.println for logging.

The new method stopAndLogTimeInMillisWithSysOut() uses System.out.println to log the execution time. While this might be intended as a temporary solution to a specific logging issue, using System.out.println is generally not recommended in production environments due to its synchronous nature and potential to slow down the application if the output buffer gets full.

Here are a few suggestions:

  • Temporary File Logging: If the standard logging is not working due to a bug, consider logging to a temporary file. This can be done using FileWriter or similar in Java, which might not be affected by the same issue as your logging framework.
  • External Logging Service: If feasible, use an external logging service API that can asynchronously handle log messages.
  • Review the Root Cause: It might be beneficial to prioritize fixing the underlying issue with the logging framework to revert to a more robust logging method sooner.

These alternatives could provide a more reliable and maintainable solution while the underlying logging issue is being resolved.

Copy link
Contributor

@sneha122 sneha122 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NilanshBansal NilanshBansal merged commit 1c14d69 into release Sep 5, 2024
44 checks passed
@NilanshBansal NilanshBansal deleted the chore/issue-35568/adding-thread-info-plugins branch September 5, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration ok-to-test Required label for CI Query & JS Pod Issues related to the query & JS Pod skip-changelog Adding this label to a PR prevents it from being listed in the changelog Stability Issue Every issue handle by Stability Pod Stability Pod For all issues/tasks to be prioritized under Stability pod Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Add Java thread information in the Plugin Module
2 participants