Skip to content

ROB-1741: datadog rds analysis toolset - #653

Merged
nherment merged 30 commits into
masterfrom
rob-1741_datadog_db_analysis_toolset
Aug 5, 2025
Merged

nherment merged 30 commits into
masterfrom
rob-1741_datadog_db_analysis_toolset

Conversation

@nherment

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 18, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This change introduces a new Datadog RDS toolset for performance analysis of AWS RDS instances. It adds toolset registration, tool implementations for generating performance reports and identifying worst-performing instances, an instruction template, and comprehensive integration and live tests. No existing logic is modified.

Changes

File(s) Change Summary
Toolset registration
holmes/plugins/toolsets/__init__.py
Registered and imported DatadogRDSToolset in the toolset loader.
Datadog RDS toolset implementation
holmes/plugins/toolsets/datadog/toolset_datadog_rds.py
Added new file implementing DatadogRDSToolset, tools for RDS performance reporting, and config.
Instruction template
holmes/plugins/toolsets/datadog/datadog_rds_instructions.jinja2
Added new instruction template for Datadog RDS performance tools usage and interpretation.
Integration tests (mocked)
tests/plugins/toolsets/datadog/rds/test_datadog_rds_integration.py
Added integration tests for the Datadog RDS toolset using mocked Datadog API responses.
Live integration tests
tests/plugins/toolsets/datadog/rds/test_datadog_rds_live.py
Added live integration tests for the Datadog RDS toolset using real Datadog API credentials.
Docstring addition
holmes/plugins/toolsets/datadog/toolset_datadog_traces.py
Added module-level docstring describing the Datadog Traces toolset for HolmesGPT.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Toolset (DatadogRDSToolset)
    participant Tool (GenerateRDSPerformanceReport)
    participant DatadogAPI

    User->>Toolset: Selects GenerateRDSPerformanceReport tool
    Toolset->>Tool: Invokes with parameters (instance, time range)
    Tool->>DatadogAPI: Queries metrics for RDS instance
    DatadogAPI-->>Tool: Returns metrics data
    Tool->>Tool: Aggregates, analyzes, and formats report
    Tool->>Toolset: Returns structured report
    Toolset->>User: Presents performance report
Loading
sequenceDiagram
    participant User
    participant Toolset (DatadogRDSToolset)
    participant Tool (GetTopWorstPerformingRDSInstances)
    participant DatadogAPI

    User->>Toolset: Selects GetTopWorstPerformingRDSInstances tool
    Toolset->>Tool: Invokes with parameters (sort, time range)
    Tool->>DatadogAPI: Lists all RDS instances
    DatadogAPI-->>Tool: Returns instance list
    loop For each instance (up to 50)
        Tool->>DatadogAPI: Queries metrics for instance
        DatadogAPI-->>Tool: Returns metrics
        Tool->>Tool: Scores and analyzes issues
    end
    Tool->>Tool: Sorts and formats summary report
    Tool->>Toolset: Returns summary report
    Toolset->>User: Presents worst-performing instances
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • arikalon1
  • moshemorad

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a46b64e and 9c6df5f.

📒 Files selected for processing (1)
  • holmes/plugins/toolsets/datadog/toolset_datadog_traces.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • holmes/plugins/toolsets/datadog/toolset_datadog_traces.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Pre-commit checks
  • GitHub Check: llm_evals
  • GitHub Check: Pre-commit checks
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob-1741_datadog_db_analysis_toolset

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@nherment
nherment requested review from arikalon1 and moshemorad July 18, 2025 14:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
holmes/plugins/toolsets/datadog/toolset_datadog_rds.py (2)

374-374: Consider making the instance limit configurable

The hard-coded limit of 50 instances might be insufficient for large environments. Consider making this configurable.

-            for instance_id in instances[:50]:  # Limit to 50 instances to avoid timeout
+            max_instances = min(50, params.get("max_instances_to_analyze", 50))
+            for instance_id in instances[:max_instances]:  # Limit instances to avoid timeout

Also add a parameter definition in the tool's __init__ method:

"max_instances_to_analyze": ToolParameter(
    description="Maximum number of instances to analyze (default: 50, max: 50)",
    type="number",
    required=False,
),

93-98: Consider consolidating config None checks

Multiple tools check for None config. Consider adding a property or method to handle this consistently.

Add a helper method to the base class:

def _ensure_config(self, params: Any) -> Optional[StructuredToolResult]:
    """Check if config is available, return error result if not."""
    if not self.toolset.dd_config:
        return StructuredToolResult(
            status=ToolResultStatus.ERROR,
            error=TOOLSET_CONFIG_MISSING_ERROR,
            params=params,
        )
    return None

Then use it in tools:

-        if not self.toolset.dd_config:
-            return StructuredToolResult(
-                status=ToolResultStatus.ERROR,
-                error=TOOLSET_CONFIG_MISSING_ERROR,
-                params=params,
-            )
+        config_error = self._ensure_config(params)
+        if config_error:
+            return config_error
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 43e7ee1 and 6c33c70.

📒 Files selected for processing (5)
  • holmes/plugins/toolsets/__init__.py (2 hunks)
  • holmes/plugins/toolsets/datadog/datadog_rds_instructions.jinja2 (1 hunks)
  • holmes/plugins/toolsets/datadog/toolset_datadog_rds.py (1 hunks)
  • tests/plugins/toolsets/datadog/rds/test_datadog_rds_integration.py (1 hunks)
  • tests/plugins/toolsets/datadog/rds/test_datadog_rds_live.py (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: nherment
PR: robusta-dev/holmesgpt#436
File: tests/llm/fixtures/test_ask_holmes/42_dns_issues_result_new_tools/toolsets.yaml:6-20
Timestamp: 2025-06-05T06:14:11.571Z
Learning: nherment prefers to keep test fixtures simple rather than adding complex security restrictions, even when potential security issues are identified.
holmes/plugins/toolsets/datadog/toolset_datadog_rds.py (1)
Learnt from: nherment
PR: robusta-dev/holmesgpt#535
File: holmes/plugins/toolsets/bash/bash_toolset.py:207-209
Timestamp: 2025-06-24T05:51:04.543Z
Learning: The init_config method in toolsets should be idempotent - safely callable multiple times without errors. self.config should maintain consistent typing (not alternate between dict and config object types) throughout the object lifecycle.
🧬 Code Graph Analysis (1)
holmes/plugins/toolsets/__init__.py (1)
holmes/plugins/toolsets/datadog/toolset_datadog_rds.py (1)
  • DatadogRDSToolset (581-657)
🪛 GitHub Actions: Build and test HolmesGPT
holmes/plugins/toolsets/datadog/datadog_rds_instructions.jinja2

[error] 79-79: Pre-commit hook 'end-of-file-fixer' modified file to fix missing newline at end of file.

holmes/plugins/toolsets/datadog/toolset_datadog_rds.py

[error] 137-564: Mypy type checking errors: Unsupported target for indexed assignment, attribute access on None or object types, and incompatible argument types found in multiple lines.

🪛 Ruff (0.12.2)
tests/plugins/toolsets/datadog/rds/test_datadog_rds_live.py

14-14: datetime.datetime imported but unused

Remove unused import

(F401)


14-14: datetime.timezone imported but unused

Remove unused import

(F401)


14-14: datetime.timedelta imported but unused

Remove unused import

(F401)

tests/plugins/toolsets/datadog/rds/test_datadog_rds_integration.py

9-9: unittest.mock.Mock imported but unused

Remove unused import: unittest.mock.Mock

(F401)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: llm_evals
🔇 Additional comments (1)
holmes/plugins/toolsets/__init__.py (1)

24-26: LGTM!

The import and registration of DatadogRDSToolset follows the established pattern for other Datadog toolsets.

Also applies to: 83-83

Comment thread holmes/plugins/toolsets/datadog/datadog_rds_instructions.jinja2 Outdated
Comment thread tests/plugins/toolsets/datadog/rds/test_datadog_rds_live.py Outdated
Comment thread tests/plugins/toolsets/datadog/rds/test_datadog_rds_integration.py Outdated
Comment thread holmes/plugins/toolsets/datadog/toolset_datadog_rds.py Outdated
Comment thread holmes/plugins/toolsets/datadog/toolset_datadog_rds.py
Base automatically changed from rob-1739_datadog_traces_toolset to master July 18, 2025 19:27
@nherment
nherment enabled auto-merge (squash) August 4, 2025 12:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
holmes/plugins/toolsets/datadog/datadog_rds_instructions.jinja2 (1)

45-82: Add missing newline at end of file

The content provides excellent guidance on scenarios, result interpretation, and workflows. However, the file still lacks a trailing newline character, which was flagged in a previous review.

Apply this diff to add the missing newline:

-Always consider the time range - recent data (last hour) for current issues, longer ranges (last 24 hours) for trends.
+Always consider the time range - recent data (last hour) for current issues, longer ranges (last 24 hours) for trends.
+
🧹 Nitpick comments (1)
holmes/plugins/toolsets/datadog/datadog_rds_instructions.jinja2 (1)

36-44: Consider reviewing the memory threshold.

The performance thresholds are well-defined and reasonable. However, the 100MB freeable memory warning threshold might be too aggressive for larger RDS instances (e.g., instances with 64GB+ RAM). Consider making this threshold relative to total memory or instance class.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 026e4bf and a46b64e.

📒 Files selected for processing (4)
  • holmes/plugins/toolsets/datadog/datadog_rds_instructions.jinja2 (1 hunks)
  • holmes/plugins/toolsets/datadog/toolset_datadog_rds.py (1 hunks)
  • tests/plugins/toolsets/datadog/rds/test_datadog_rds_integration.py (1 hunks)
  • tests/plugins/toolsets/datadog/rds/test_datadog_rds_live.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/plugins/toolsets/datadog/rds/test_datadog_rds_live.py
  • tests/plugins/toolsets/datadog/rds/test_datadog_rds_integration.py
  • holmes/plugins/toolsets/datadog/toolset_datadog_rds.py
🔇 Additional comments (2)
holmes/plugins/toolsets/datadog/datadog_rds_instructions.jinja2 (2)

1-4: LGTM!

Clear and informative introduction that sets proper expectations for the Datadog RDS analysis tools.


5-18: LGTM!

Well-structured tool descriptions that clearly explain functionality and expected outputs for both RDS analysis tools.

@github-actions

github-actions Bot commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 22/36 test cases were successful, 0 regressions, 1 skipped, 13 mock failures
Test suite Test case Status
ask 01_how_many_pods ✅
ask 02_what_is_wrong_with_pod 🔧
ask 03_what_is_the_command_to_port_forward 🔧
ask 04_related_k8s_events ↪️
ask 05_image_version 🔧
ask 09_crashpod ✅
ask 10_image_pull_backoff 🔧
ask 11_init_containers ✅
ask 14_pending_resources ✅
ask 15_failed_readiness_probe ✅
ask 17_oom_kill ✅
ask 18_crash_looping_v2 ✅
ask 19_detect_missing_app_details 🔧
ask 24_misconfigured_pvc 🔧
ask 28_permissions_error ✅
ask 29_events_from_alert_manager ✅
ask 39_failed_toolset 🔧
ask 41_setup_argo ✅
ask 42_dns_issues_steps_new_tools 🔧
ask 43_current_datetime_from_prompt ✅
ask 45_fetch_deployment_logs_simple ✅
ask 51_logs_summarize_errors 🔧
ask 53_logs_find_term ✅
ask 54_not_truncated_when_getting_pods 🔧
ask 59_label_based_counting ✅
ask 60_count_less_than 🔧
ask 61_exact_match_counting ✅
ask 63_fetch_error_logs_no_errors ✅
ask 77_liveness_probe_misconfiguration 🔧
ask 79_configmap_mount_issue 🔧
ask 83_secret_not_found 🔧
ask 86_configmap_like_but_secret 🔧
ask 89_runbook_missing_cloudwatch 🔧
ask 90_runbook_basic_selection 🔧
ask 24a_misconfigured_pvc_basic 🔧
ask 13a_pending_node_selector_basic 🔧

Legend

  • ✅ the test was successful
  • ↪️ the test was skipped
  • ⚠️ the test failed but is known to be flaky or known to fail
  • 🔧 the test failed due to mock data issues (not a code regression)
  • ❌ the test failed and should be fixed before merging the PR

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.

2 participants