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

Add cognee config to telemetry #265

Merged
merged 4 commits into from
Dec 7, 2024

Conversation

alekszievr
Copy link
Contributor

@alekszievr alekszievr commented Dec 6, 2024

image

Summary by CodeRabbit

  • New Features
    • Enhanced logging capabilities for pipeline execution, including detailed configuration data.
  • Bug Fixes
    • Improved error handling and telemetry reporting during task execution.

Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

Walkthrough

The changes in the pull request primarily focus on modifying the run_tasks.py file to enhance the run_tasks_with_telemetry function. This function now includes a new variable, config, populated by get_current_settings(), which is logged for better visibility. The run_tasks function has been simplified to directly call run_tasks_with_telemetry, removing previous configuration retrieval. Import statements have been rearranged for clarity. Overall, these modifications improve logging and telemetry without altering the existing control flow or introducing new logic.

Changes

File Path Change Summary
cognee/modules/pipelines/operations/run_tasks.py Updated run_tasks_with_telemetry to include a new variable config. Simplified run_tasks to call run_tasks_with_telemetry directly. Rearranged import statements for clarity. Error handling remains consistent with enhanced telemetry reporting.

Poem

In the code where tasks do run,
A config now logs, oh what fun!
With telemetry bright,
We trace day and night,
Enhancing our flow, we’ve just begun! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ff35912 and 462fcef.

📒 Files selected for processing (1)
  • cognee/modules/pipelines/operations/run_tasks.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cognee/modules/pipelines/operations/run_tasks.py

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

@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 (3)
cognee/modules/pipelines/operations/run_tasks.py (3)

164-166: Add config parameter validation and error handling

While the configuration logging is a good addition, consider adding validation and error handling:

  1. Validate that the config dictionary is not None
  2. Handle potential JSON serialization errors for non-serializable config values
 async def run_tasks_with_telemetry(tasks: list[Task], data, pipeline_name: str, config: dict):
+    if config is None:
+        config = {}
+    try:
         logger.debug("\nRunning pipeline with configuration:\n%s\n", json.dumps(config, indent = 1))
+    except TypeError as e:
+        logger.warning(f"Failed to serialize config for logging: {str(e)}")
+        logger.debug("\nRunning pipeline with non-serializable configuration\n")

173-174: Consider including config in all telemetry events

The configuration is only included in the "Pipeline Run Started" event. For consistency and debugging purposes, consider including it in "Pipeline Run Completed" and "Pipeline Run Errored" events as well.


198-200: Add error handling for settings retrieval

The settings retrieval could fail. Consider adding error handling to ensure the pipeline can still run with default configuration if settings retrieval fails.

 async def run_tasks(tasks: list[Task], data = None, pipeline_name: str = "default_pipeline"):
-    config = get_current_settings()
+    try:
+        config = get_current_settings()
+    except Exception as e:
+        logger.warning(f"Failed to retrieve settings: {str(e)}. Using default configuration.")
+        config = {}

     async for result in run_tasks_with_telemetry(tasks, data, pipeline_name, config):
         yield result
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 348610e and ff35912.

📒 Files selected for processing (1)
  • cognee/modules/pipelines/operations/run_tasks.py (3 hunks)
🔇 Additional comments (2)
cognee/modules/pipelines/operations/run_tasks.py (2)

2-2: LGTM: Import changes are appropriate

The reorganized imports maintain clean structure and include all necessary dependencies for the new configuration logging functionality.

Also applies to: 8-8


Line range hint 164-200: Verify telemetry data handling

Please ensure that:

  1. All direct calls to run_tasks_with_telemetry are updated with the config parameter
  2. Monitoring systems can handle the additional configuration data in telemetry events
✅ Verification successful

Let me gather more information about the telemetry data handling.


No changes needed for telemetry handling

The telemetry implementation is safe and properly handles the additional configuration data:

  1. The only direct call to run_tasks_with_telemetry is from within the run_tasks function, which correctly provides all required parameters including the config.
  2. The telemetry system, implemented in shared/utils.py, accepts arbitrary additional properties through its additional_properties parameter, making it compatible with the configuration data being passed.
  3. The pipeline telemetry events ("Pipeline Run Started", "Pipeline Run Completed", "Pipeline Run Errored") are consistently used across the codebase.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct calls to run_tasks_with_telemetry
rg "run_tasks_with_telemetry\(" --type py -B 2 -A 2

Length of output: 863


Script:

#!/bin/bash
# Search for telemetry event handling and monitoring
rg "send_telemetry\(" --type py -B 2 -A 2

# Search for any configuration related telemetry processing
rg "Pipeline Run Started" --type py -B 2 -A 2

Length of output: 15135

@@ -190,7 +195,6 @@ async def run_tasks_with_telemetry(tasks: list[Task], data, pipeline_name: str):

async def run_tasks(tasks: list[Task], data = None, pipeline_name: str = "default_pipeline"):
config = get_current_settings()
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move also this config inside run_tasks_with_telemetry, then we don't have to pass it in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

})

} | config
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This formatting looks like there is some issue with the code. :) Maybe move the closing bracket ) up with config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

dexters1
dexters1 previously approved these changes Dec 6, 2024
….py and make the indentation a bit more readable
Copy link

gitguardian bot commented Dec 6, 2024

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9573981 Triggered Generic Password f30bf35 cognee/tests/test_deduplication.py View secret
9573981 Triggered Generic Password f30bf35 .github/workflows/test_deduplication.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@Vasilije1990 Vasilije1990 self-requested a review December 7, 2024 08:45
@Vasilije1990 Vasilije1990 merged commit ce96431 into main Dec 7, 2024
39 of 40 checks passed
@Vasilije1990 Vasilije1990 deleted the feat/COG-418-log-config-to-telemetry branch December 7, 2024 08:45
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.

4 participants