Skip to content

Conversation

@borisarzentar
Copy link
Member

Description

DCO Affirmation

I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.

@borisarzentar borisarzentar self-assigned this Apr 25, 2025
@pull-checklist
Copy link

pull-checklist bot commented Apr 25, 2025

Please make sure all the checkboxes are checked:

  • I have tested these changes locally.
  • I have reviewed the code changes.
  • I have added end-to-end and unit tests (if applicable).
  • I have updated the documentation and README.md file (if necessary).
  • I have removed unnecessary code and debug statements.
  • PR title is clear and follows the convention.
  • I have tagged reviewers or team members for feedback.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 25, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update refactors the observability and monitoring infrastructure throughout the codebase. The legacy MonitoringTool enum is removed and replaced by a new Observer enum, now defined in a dedicated module. A new utility function, get_observe(), is introduced to centralize and standardize the retrieval of the observability decorator, replacing prior conditional import logic. All affected modules are updated to use this new approach, with import statements reorganized and references to the old enum and logic eliminated. No public API signatures are changed, except for the default value of a configuration attribute.

Changes

Files / Paths Change Summary
cognee/api/v1/cognify/code_graph_pipeline.py, cognee/infrastructure/llm/gemini/adapter.py, cognee/infrastructure/llm/openai/adapter.py Refactored imports to use new get_observe() utility; removed conditional imports and references to MonitoringTool.
cognee/base_config.py Replaced MonitoringTool with Observer for the monitoring_tool config attribute; updated import order.
cognee/modules/observability/get_observe.py Introduced new module with get_observe() function to centralize observability decorator retrieval.
cognee/modules/observability/observers.py Added new Observer enum to define supported monitoring tools.
cognee/shared/data_models.py Removed the MonitoringTool enum and its members.

Sequence Diagram(s)

sequenceDiagram
    participant Module as Any Module (e.g., Adapter)
    participant GetObserve as get_observe()
    participant Config as BaseConfig
    participant ObserverEnum as Observer
    participant Decorator as langfuse.decorators.observe

    Module->>GetObserve: Call get_observe()
    GetObserve->>Config: Retrieve monitoring_tool from config
    GetObserve->>ObserverEnum: Compare tool to Observer.LANGFUSE
    alt If LANGFUSE
        GetObserve->>Decorator: Import observe decorator
        GetObserve-->>Module: Return observe
    else Not supported
        GetObserve-->>Module: Return None
    end
Loading

Possibly related PRs

Suggested labels

run-checks

Poem

A hop and a skip, the code’s now more clear,
Observers in line, enum changes appear!
No more old tools, just one place to see—
get_observe() brings observability.
With enums refactored and imports anew,
This rabbit is happy—how about you?
🐇✨


🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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 comments (1)
cognee/modules/observability/get_observe.py (1)

1-12: 🛠️ Refactor suggestion

Add handling for non-LANGFUSE observers and include docstring

This new module effectively centralizes the observability decorator acquisition, but has two issues:

  1. It doesn't explicitly handle cases where monitoring isn't LANGFUSE. The function implicitly returns None, which could cause errors when clients attempt to use the returned value as a decorator.

  2. Missing docstring to explain the function's purpose and behavior.

 def get_observe():
+    """
+    Returns the appropriate observe decorator based on the configured monitoring tool.
+    
+    Returns:
+        callable: The observe decorator if supported monitoring tool is configured
+        None: If no supported monitoring tool is configured
+    """
     monitoring = get_base_config().monitoring_tool

     if monitoring == Observer.LANGFUSE:
         from langfuse.decorators import observe

         return observe
+    # For future monitoring tools, add additional handlers here
+    
+    # Return no-op decorator as fallback
+    return lambda *args, **kwargs: (lambda f: f)
🧹 Nitpick comments (1)
cognee/base_config.py (1)

11-11: Use specific type hint instead of 'object'

The type hint for monitoring_tool is very generic (object). Consider using the actual Observer enum type for better code clarity and IDE support.

-    monitoring_tool: object = Observer.LANGFUSE
+    monitoring_tool: Observer = Observer.LANGFUSE
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f94076b and 84ee029.

📒 Files selected for processing (7)
  • cognee/api/v1/cognify/code_graph_pipeline.py (2 hunks)
  • cognee/base_config.py (1 hunks)
  • cognee/infrastructure/llm/gemini/adapter.py (1 hunks)
  • cognee/infrastructure/llm/openai/adapter.py (2 hunks)
  • cognee/modules/observability/get_observe.py (1 hunks)
  • cognee/modules/observability/observers.py (1 hunks)
  • cognee/shared/data_models.py (0 hunks)
💤 Files with no reviewable changes (1)
  • cognee/shared/data_models.py
🧰 Additional context used
🧬 Code Graph Analysis (5)
cognee/infrastructure/llm/openai/adapter.py (1)
cognee/modules/observability/get_observe.py (1)
  • get_observe (5-11)
cognee/base_config.py (2)
cognee/modules/observability/observers.py (1)
  • Observer (4-9)
cognee/api/v1/config/config.py (1)
  • monitoring_tool (37-39)
cognee/infrastructure/llm/gemini/adapter.py (5)
cognee/shared/logging_utils.py (1)
  • get_logger (137-158)
cognee/modules/observability/get_observe.py (1)
  • get_observe (5-11)
cognee/exceptions/exceptions.py (1)
  • InvalidValueError (38-45)
cognee/infrastructure/llm/prompts/read_query_prompt.py (1)
  • read_query_prompt (6-22)
cognee/infrastructure/llm/rate_limiter.py (2)
  • rate_limit_async (220-243)
  • sleep_and_retry_async (331-376)
cognee/modules/observability/get_observe.py (3)
cognee/base_config.py (1)
  • get_base_config (29-30)
cognee/modules/observability/observers.py (1)
  • Observer (4-9)
cognee/api/v1/config/config.py (1)
  • monitoring_tool (37-39)
cognee/api/v1/cognify/code_graph_pipeline.py (3)
cognee/shared/logging_utils.py (1)
  • get_logger (137-158)
cognee/modules/observability/get_observe.py (1)
  • get_observe (5-11)
cognee/shared/data_models.py (2)
  • KnowledgeGraph (33-39)
  • KnowledgeGraph (63-67)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: End-to-End Tests / Run Telemetry Pipeline Test
  • GitHub Check: End-to-End Tests / Server Start Test
  • GitHub Check: End-to-End Tests / S3 Bucket Test
  • GitHub Check: End-to-End Tests / Deletion Test
  • GitHub Check: End-to-End Tests / Deduplication Test
  • GitHub Check: Basic Tests / Run Unit Tests
  • GitHub Check: Basic Tests / Run Simple Examples
  • GitHub Check: Basic Tests / Run Basic Graph Tests
  • GitHub Check: Basic Tests / Run Integration Tests
🔇 Additional comments (6)
cognee/infrastructure/llm/gemini/adapter.py (2)

6-7: Improved import organization

The imports have been nicely reorganized to use the new centralized observability module.


17-17: Good usage of the centralized observability function

Using get_observe() centralizes the observability configuration logic, making the code cleaner and more maintainable than having conditional imports scattered throughout the codebase.

cognee/modules/observability/observers.py (1)

4-9: Well-structured Observer enum

The Observer enum is well-structured as a string enum, allowing easy string comparison. This makes the code more maintainable by centralizing all supported monitoring tools in a single location.

cognee/base_config.py (1)

5-6: Import order and module selection look good

The new import from the dedicated observability module is appropriate.

cognee/infrastructure/llm/openai/adapter.py (1)

5-6: Clean refactoring of observability imports

The code now uses the new abstracted observability pattern with get_observe() instead of directly importing and conditionally handling monitoring tools. This simplifies the code and aligns with the PR's goal of abstracting logging tool integration.

Also applies to: 18-18, 20-20

cognee/api/v1/cognify/code_graph_pipeline.py (1)

5-7: Good simplification of observability pattern

The changes properly implement the new abstracted observability pattern by:

  1. Adding the import for get_observe
  2. Removing unnecessary imports from cognee.shared.data_models (keeping only KnowledgeGraph)
  3. Using observe = get_observe() to centralize the decorator retrieval

This approach makes the codebase more maintainable and follows the single responsibility principle.

Also applies to: 14-14, 24-24

hande-k and others added 2 commits April 26, 2025 00:03
<!-- .github/pull_request_template.md -->

## Description
<!-- Provide a clear description of the changes in this PR -->

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.

---------

Co-authored-by: Vasilije <[email protected]>
@borisarzentar borisarzentar changed the base branch from main to dev April 29, 2025 11:24
@borisarzentar borisarzentar merged commit 9729547 into dev Apr 30, 2025
49 checks passed
@borisarzentar borisarzentar deleted the feature/cog-1675-abstract-logging-tool-integration branch April 30, 2025 10:58
Copy link
Contributor

@soobrosa soobrosa left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants