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

fix: logs for lineage error #1517

Merged
merged 2 commits into from
Dec 10, 2024
Merged

fix: logs for lineage error #1517

merged 2 commits into from
Dec 10, 2024

Conversation

saravmajestic
Copy link
Collaborator

@saravmajestic saravmajestic commented Dec 3, 2024

Overview

Problem

  • Extension stops working after some time in windows machines

Solution

  • Optimized discovering projects by ignoring unnecessary directories
  • added logs to give more information about the error

Screenshot/Demo

A picture is worth a thousand words. Please highlight the changes if applicable.

How to test

  • Steps to be followed to verify the solution or code changes
  • Mention if there is any settings configuration added/changed/deleted

Checklist

  • I have run this code and it appears to resolve the stated issue
  • README.md updated and added information about my change

Important

Optimize project discovery and add logging for error tracking in dbtWorkspaceFolder.ts and newLineagePanel.ts.

  • Behavior:
    • Optimized project discovery in discoverProjects() in dbtWorkspaceFolder.ts by excluding dbt_packages and site-packages directories.
    • Added logging in getStartingNode() in newLineagePanel.ts to log when no event or node is found.
  • Misc:
    • Added comments to clarify exclusion patterns in discoverProjects() in dbtWorkspaceFolder.ts.

This description was created by Ellipsis for 8375d7a. It will automatically update as commits are pushed.


Summary by CodeRabbit

  • New Features

    • Enhanced project discovery by excluding specific directories (dbt_packages and site-packages) from the search.
    • Improved error handling and logging in the lineage panel, providing clearer insights when events or nodes are not found.
    • Added the ability to indicate if the Altimate feature is enabled within the lineage data.
  • Bug Fixes

    • Enhanced logging for better traceability during execution in the lineage panel.

Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Walkthrough

The pull request introduces changes to two files: dbtWorkspaceFolder.ts and newLineagePanel.ts. In dbtWorkspaceFolder.ts, the discoverProjects method is modified to exclude specific directories (dbt_packages and site-packages) when discovering DBT project files. In newLineagePanel.ts, the getStartingNode method is enhanced with additional logging for improved error handling and now returns an object indicating whether the Altimate feature is enabled. No public entity signatures are altered in either file.

Changes

File Path Change Summary
src/manifest/dbtWorkspaceFolder.ts Modified discoverProjects to add an exclusion pattern for dbt_packages and site-packages.
src/webview_provider/newLineagePanel.ts Updated getStartingNode to include logging for missing events/nodes and return an object with aiEnabled.

Suggested reviewers

  • mdesmet
  • AdiGajbhiye

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to eb9f997 in 21 seconds

More details
  • Looked at 43 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. src/webview_provider/newLineagePanel.ts:479
  • Draft comment:
    Consider using debug instead of info for this log statement, as it is primarily for debugging purposes.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The logging statements added in the getStartingNode method are useful for debugging, but the log level used is info. It might be more appropriate to use debug for these logs, as they are primarily for development and debugging purposes, not for general information logging.
2. src/webview_provider/newLineagePanel.ts:490
  • Draft comment:
    Consider using debug instead of info for this log statement, as it is primarily for debugging purposes.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The logging statements added in the getStartingNode method are useful for debugging, but the log level used is info. It might be more appropriate to use debug for these logs, as they are primarily for development and debugging purposes, not for general information logging.
3. src/webview_provider/newLineagePanel.ts:476
  • Draft comment:
    Please specify a return type for the function getStartingNode. This will help in refactoring and understanding the code better.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_shAGTets1sgKjiXs


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@saravmajestic saravmajestic self-assigned this Dec 3, 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: 0

🧹 Outside diff range and nitpick comments (2)
src/manifest/dbtWorkspaceFolder.ts (1)

85-92: LGTM! Consider extracting the exclude pattern as a constant.

The implementation correctly excludes dbt_packages and site-packages directories from project discovery, which will improve performance by avoiding unnecessary scans.

Consider extracting the exclude pattern as a class constant for better maintainability:

+  private static readonly PROJECT_EXCLUDE_PATTERN = "**/{dbt_packages,site-packages}";

   async discoverProjects() {
-    const excludePattern = "**/{dbt_packages,site-packages}";
+    const excludePattern = DBTWorkspaceFolder.PROJECT_EXCLUDE_PATTERN;
src/webview_provider/newLineagePanel.ts (1)

489-492: LGTM! Consider adding null check for tableName.

The added logging will help track cases where nodes cannot be found. However, tableName is derived from getFilename() which assumes window.activeTextEditor is not null.

Consider adding a null check:

   const tableName = this.getFilename();
+  if (!tableName) {
+    this.dbtTerminal.info("Lineage:getStartingNode", "No active file");
+    return {
+      aiEnabled,
+      missingLineageMessage: this.getMissingLineageMessage(),
+    };
+  }
   const _node = nodeMetaMap.lookupByBaseName(tableName);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ddda6f6 and eb9f997.

📒 Files selected for processing (2)
  • src/manifest/dbtWorkspaceFolder.ts (1 hunks)
  • src/webview_provider/newLineagePanel.ts (2 hunks)
🔇 Additional comments (1)
src/webview_provider/newLineagePanel.ts (1)

479-479: LGTM! Appropriate logging for event not found scenario.

The added log message will help in diagnosing issues when lineage data is unavailable.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 8375d7a in 19 seconds

More details
  • Looked at 16 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. src/webview_provider/newLineagePanel.ts:463
  • Draft comment:
    Consider providing a more descriptive error message to give better context in the logs. For example, include information about the operation being attempted or the state of the application.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error logging added in the catch block is a good addition for debugging purposes. However, the error message should be more descriptive to provide better context when reviewing logs.
2. src/webview_provider/newLineagePanel.ts:460
  • Draft comment:
    Please specify a return type for the getMissingLineageMessage function to ensure easier refactoring and better readability.
  • Reason this comment was not posted:
    Comment was not on a valid diff hunk.

Workflow ID: wflow_aiBbtvJ2xkO9xCLp


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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

🧹 Outside diff range and nitpick comments (1)
src/webview_provider/newLineagePanel.ts (1)

494-497: LGTM! Good logging implementation with context.

The added logging with table name context will help track cases where nodes cannot be found, aiding in debugging lineage issues.

Consider refactoring the method to reduce duplication in the error handling paths:

 private getStartingNode():
   | {
       node?: Table;
       aiEnabled: boolean;
       missingLineageMessage?: { message: string; type: string };
     }
   | undefined {
   const aiEnabled = this.altimate.enabled();
+  const getErrorResponse = (message: string) => ({
+    aiEnabled,
+    missingLineageMessage: this.getMissingLineageMessage(),
+  });
+
   const event = this.queryManifestService.getEventByCurrentProject();
   if (!event?.event) {
     this.dbtTerminal.info("Lineage:getStartingNode", "No event found");
-    return {
-      aiEnabled,
-      missingLineageMessage: this.getMissingLineageMessage(),
-    };
+    return getErrorResponse("No event found");
   }
   
   const { nodeMetaMap } = event.event;
   const tableName = this.getFilename();
   const _node = nodeMetaMap.lookupByBaseName(tableName);
   if (!_node) {
     this.dbtTerminal.info(
       "Lineage:getStartingNode",
       `No node found for ${tableName}`,
     );
-    return {
-      aiEnabled,
-      missingLineageMessage: this.getMissingLineageMessage(),
-    };
+    return getErrorResponse(`No node found for ${tableName}`);
   }
   
   const key = _node.uniqueId;
   const url = window.activeTextEditor!.document.uri.path;
   const node = this.dbtLineageService.createTable(event.event, url, key);
   return { node, aiEnabled };
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between eb9f997 and 8375d7a.

📒 Files selected for processing (1)
  • src/webview_provider/newLineagePanel.ts (3 hunks)
🔇 Additional comments (2)
src/webview_provider/newLineagePanel.ts (2)

463-467: LGTM! Good error logging implementation.

The added error logging will help with debugging lineage issues, particularly when diagnostics errors occur. The implementation properly handles error types and logs both the message and full error object.


484-484: LGTM! Appropriate logging for event availability.

The info-level logging is well-placed to track when lineage cannot be generated due to missing events. This will help diagnose user-reported issues where lineage fails to display.

Copy link
Collaborator

@AdiGajbhiye AdiGajbhiye left a comment

Choose a reason for hiding this comment

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

lgtm

@anandgupta42 anandgupta42 merged commit 99a09f7 into master Dec 10, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants