holmesgpt icon indicating copy to clipboard operation
holmesgpt copied to clipboard

ROB-1267 unified tool logs api kubernetes override

Open nherment opened this issue 7 months ago • 1 comments

Summary by CodeRabbit

  • New Features

    • Added a utility to filter out default logging toolsets, improving toolset management.
  • Refactor

    • Improved internal structure by relocating and reorganizing tool and toolset utilities for better maintainability.
  • Tests

    • Introduced new unit and integration tests for toolset filtering and OpenSearch logs functionality, enhancing test coverage.
  • Chores

    • Updated import paths throughout the codebase for consistency and clarity.

nherment avatar May 20 '25 13:05 nherment

Walkthrough

This change refactors import paths throughout the codebase, moving most tool-related imports to more specific submodules such as holmes.core.tools.tools, holmes.core.tools.tool_executor, and holmes.core.tools.tools_utils. The ToolExecutor class is relocated to its own module, and a new utility function for filtering logging toolsets is introduced. Related tests are updated and expanded accordingly.

Changes

File(s) Change Summary
holmes/core/tools/tools.py Removed the ToolExecutor class and its logic from this module.
holmes/core/tools/tool_executor.py Introduced new ToolExecutor class with methods for tool invocation, tool lookup, and OpenAI-format listing. Handles toolset filtering and logging.
holmes/core/tools/toolset_utils.py Added filter_out_default_logging_toolset utility function to manage enabled logging toolsets, preferring non-default ones.
holmes/core/tools/logging_api.py, holmes/core/tool_calling_llm.py, holmes/config.py, examples/custom_llm.py, holmes/plugins/toolsets/__init__.py, holmes/plugins/toolsets/coralogix/api.py, holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py, holmes/plugins/toolsets/datadog.py, holmes/plugins/toolsets/datetime.py, holmes/plugins/toolsets/git.py, holmes/plugins/toolsets/grafana/base_grafana_toolset.py, holmes/plugins/toolsets/grafana/common.py, holmes/plugins/toolsets/grafana/toolset_grafana.py, holmes/plugins/toolsets/grafana/toolset_grafana_loki.py, holmes/plugins/toolsets/grafana/toolset_grafana_tempo.py, holmes/plugins/toolsets/grafana/trace_parser.py, holmes/plugins/toolsets/internet/internet.py, holmes/plugins/toolsets/internet/notion.py, holmes/plugins/toolsets/kafka.py, holmes/plugins/toolsets/kubernetes_logs.py, holmes/plugins/toolsets/newrelic.py, holmes/plugins/toolsets/opensearch/opensearch.py, holmes/plugins/toolsets/opensearch/opensearch_logs.py, holmes/plugins/toolsets/opensearch/opensearch_traces.py, holmes/plugins/toolsets/opensearch/opensearch_utils.py, holmes/plugins/toolsets/prometheus/prometheus.py, holmes/plugins/toolsets/rabbitmq/toolset_rabbitmq.py, holmes/plugins/toolsets/robusta/robusta.py, holmes/utils/holmes_sync_toolsets.py Updated import paths for tool and toolset entities to use holmes.core.tools.tools or related submodules for better modularity.
tests/core/tools/test_toolset_utils.py New test file with unit tests for filter_out_default_logging_toolset, using dummy toolset classes to verify filtering logic.
tests/plugins/toolsets/opensearch/test_opensearch_logs_integration.py New integration test file for OpenSearch logs toolset, including fixtures and tests for health check, basic query, search term, and date range filtering.
tests/llm/test_ask_holmes.py, tests/llm/test_investigate.py, tests/llm/test_mocks.py, tests/llm/utils/mock_toolset.py, tests/llm/utils/mock_utils.py, tests/plugins/prompt/test_fetch_logs.py, tests/plugins/prompt/test_generic_ask_conversation.py, tests/plugins/prompt/test_toolsets_instructions.py, tests/plugins/toolsets/grafana/test_grafana_loki.py, tests/plugins/toolsets/grafana/test_grafana_tempo.py, tests/plugins/toolsets/kubernetes/test_kubernetes_logs.py, tests/plugins/toolsets/kubernetes/test_kubernetes_logs_filter_by_timestamp.py, tests/plugins/toolsets/opensearch/test_opensearch_integration.py, tests/plugins/toolsets/test_internet.py, tests/plugins/toolsets/test_notion.py, tests/plugins/toolsets/test_prometheus_integration.py, tests/plugins/toolsets/test_tool_kafka.py, tests/plugins/toolsets/test_toolset_utils.py, tests/test_holmes_sync_toolsets.py, tests/test_structured_toolcall_result.py Updated test imports to match new module structure for tools, toolsets, and related enums/classes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ToolExecutor
    participant Toolset(s)
    participant Tool

    User->>ToolExecutor: invoke(tool_name, params)
    ToolExecutor->>Tool: get_tool_by_name(tool_name)
    alt Tool found
        ToolExecutor->>Tool: invoke(params)
        Tool-->>ToolExecutor: StructuredToolResult
        ToolExecutor-->>User: StructuredToolResult
    else Tool not found
        ToolExecutor-->>User: StructuredToolResult (error)
    end
sequenceDiagram
    participant System
    participant Toolset(s)
    participant ToolsetUtils

    System->>ToolsetUtils: filter_out_default_logging_toolset(toolsets)
    ToolsetUtils->>Toolset(s): check enabled status and names
    ToolsetUtils-->>System: filtered toolsets (at most one logging toolset, prefer non-default)

Suggested reviewers

  • moshemorad
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

coderabbitai[bot] avatar May 20 '25 13:05 coderabbitai[bot]