Skip to content

Print logger name on logs tool calls - #670

Merged
aantn merged 6 commits into
masterfrom
named-logging-calls
Jul 22, 2025
Merged

aantn merged 6 commits into
masterfrom
named-logging-calls

Conversation

@arikalon1

Copy link
Copy Markdown
Collaborator

No description provided.

@arikalon1
arikalon1 requested a review from aantn July 21, 2025 14:57
@coderabbitai

coderabbitai Bot commented Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This change introduces a new logger_name method to multiple log toolset classes, returning a string identifier for each logger. The get_parameterized_one_liner method is updated to dynamically prefix descriptions with the logger name where applicable. Corresponding test assertions are updated to reflect these prefixed descriptions.

Changes

Files / Areas Changed Summary
holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py Added logger_name method to CoralogixLogsToolset, returning "Coralogix".
holmes/plugins/toolsets/datadog/toolset_datadog_logs.py Added logger_name method to DatadogLogsToolset, returning "DataDog".
holmes/plugins/toolsets/grafana/toolset_grafana_loki.py Added logger_name method to GrafanaLokiToolset, returning "Loki".
holmes/plugins/toolsets/opensearch/opensearch_logs.py Added logger_name method to OpenSearchLogsToolset, returning "OpenSearch".
holmes/plugins/toolsets/logging_utils/logging_api.py Added logger_name method to BasePodLoggingToolset (returns empty string). Updated get_parameterized_one_liner in PodLoggingTool to prefix description with logger name if present.
holmes/plugins/toolsets/datadog/toolset_datadog_traces.py Prefixed returned strings in get_parameterized_one_liner methods with "DataDog: ".
tests/plugins/toolsets/datadog/traces/test_datadog_traces.py Updated expected test strings to include "DataDog: " prefix in assertions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Tool
    participant Toolset

    User->>Tool: Invoke get_parameterized_one_liner()
    Tool->>Toolset: Call logger_name()
    Toolset-->>Tool: Return logger name (e.g., "DataDog")
    Tool->>Tool: Prefix one-liner with logger name (if non-empty)
    Tool-->>User: Return prefixed one-liner description
Loading

Estimated code review effort

2 (~15 minutes)

Possibly related PRs

Suggested reviewers

  • moshemorad
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • @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 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: 4

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 319b4dc and a3de564.

📒 Files selected for processing (6)
  • holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py (1 hunks)
  • holmes/plugins/toolsets/datadog/toolset_datadog_logs.py (1 hunks)
  • holmes/plugins/toolsets/datadog/toolset_datadog_traces.py (4 hunks)
  • holmes/plugins/toolsets/grafana/toolset_grafana_loki.py (1 hunks)
  • holmes/plugins/toolsets/logging_utils/logging_api.py (2 hunks)
  • holmes/plugins/toolsets/opensearch/opensearch_logs.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
holmes/plugins/toolsets/logging_utils/logging_api.py (2)

Learnt from: nherment
PR: #408
File: holmes/plugins/toolsets/kubernetes_logs.py:90-97
Timestamp: 2025-05-15T05:13:43.169Z
Learning: In the Kubernetes logs toolset for Holmes, both current and previous logs are intentionally fetched and combined for each pod, even though this requires more API calls. This design ensures all logs are captured even when pods restart but retain their name, providing complete diagnostic information.

Learnt from: nherment
PR: #408
File: holmes/plugins/toolsets/kubernetes_logs.py:100-102
Timestamp: 2025-05-15T05:14:06.519Z
Learning: The fetch_logs method in KubernetesLogsToolset is designed to apply the limit parameter after filtering and combining both current and previous logs, rather than using the API's tail_lines parameter, to ensure the limit applies to the final combined log set.

🧬 Code Graph Analysis (5)
holmes/plugins/toolsets/opensearch/opensearch_logs.py (4)
holmes/plugins/toolsets/grafana/toolset_grafana_loki.py (1)
  • logger_name (70-71)
holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py (1)
  • logger_name (65-66)
holmes/plugins/toolsets/datadog/toolset_datadog_logs.py (1)
  • logger_name (154-155)
holmes/plugins/toolsets/logging_utils/logging_api.py (1)
  • logger_name (45-46)
holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py (4)
holmes/plugins/toolsets/grafana/toolset_grafana_loki.py (1)
  • logger_name (70-71)
holmes/plugins/toolsets/datadog/toolset_datadog_logs.py (1)
  • logger_name (154-155)
holmes/plugins/toolsets/opensearch/opensearch_logs.py (1)
  • logger_name (69-70)
holmes/plugins/toolsets/logging_utils/logging_api.py (1)
  • logger_name (45-46)
holmes/plugins/toolsets/datadog/toolset_datadog_logs.py (4)
holmes/plugins/toolsets/grafana/toolset_grafana_loki.py (1)
  • logger_name (70-71)
holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py (1)
  • logger_name (65-66)
holmes/plugins/toolsets/opensearch/opensearch_logs.py (1)
  • logger_name (69-70)
holmes/plugins/toolsets/logging_utils/logging_api.py (1)
  • logger_name (45-46)
holmes/plugins/toolsets/grafana/toolset_grafana_loki.py (4)
holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py (1)
  • logger_name (65-66)
holmes/plugins/toolsets/datadog/toolset_datadog_logs.py (1)
  • logger_name (154-155)
holmes/plugins/toolsets/opensearch/opensearch_logs.py (1)
  • logger_name (69-70)
holmes/plugins/toolsets/logging_utils/logging_api.py (1)
  • logger_name (45-46)
holmes/plugins/toolsets/logging_utils/logging_api.py (4)
holmes/plugins/toolsets/grafana/toolset_grafana_loki.py (1)
  • logger_name (70-71)
holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py (1)
  • logger_name (65-66)
holmes/plugins/toolsets/datadog/toolset_datadog_logs.py (1)
  • logger_name (154-155)
holmes/plugins/toolsets/opensearch/opensearch_logs.py (1)
  • logger_name (69-70)
⏰ 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). (5)
  • GitHub Check: llm_evals
  • GitHub Check: Pre-commit checks
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
🔇 Additional comments (7)
holmes/plugins/toolsets/logging_utils/logging_api.py (2)

45-46: LGTM! Well-designed base implementation.

The default empty string return value provides a sensible fallback and ensures backward compatibility for any toolsets that don't override this method.


129-132: LGTM! Clean conditional prefixing logic.

The implementation correctly:

  • Only adds the logger name prefix when it's non-empty
  • Maintains backward compatibility with existing toolsets
  • Uses clear and readable conditional formatting

The f-string approach is efficient and the logic is self-documenting.

holmes/plugins/toolsets/opensearch/opensearch_logs.py (1)

69-70: LGTM! Consistent implementation.

The logger name "OpenSearch" appropriately identifies this toolset and follows the established pattern across all logging toolsets.

holmes/plugins/toolsets/grafana/toolset_grafana_loki.py (1)

70-71: LGTM! Appropriate logger identification.

The logger name "Loki" correctly identifies this Grafana Loki toolset and maintains consistency with the unified logging API pattern.

holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py (1)

65-66: LGTM! Consistent toolset identification.

The logger name "Coralogix" properly identifies this toolset and aligns with the standardized approach across all logging toolsets.

holmes/plugins/toolsets/datadog/toolset_datadog_logs.py (1)

154-155: LGTM! Consistent DataDog identification.

The logger name "DataDog" appropriately identifies this toolset and maintains consistency with the unified logging API pattern and the related DataDog traces toolset.

holmes/plugins/toolsets/datadog/toolset_datadog_traces.py (1)

204-550: No dynamic logger_name patterns detected—current hardcoded prefixes are consistent across toolsets.

A full-code search found no logger_name method definitions or usages in other toolsets, nor any dynamic one-liner prefix logic. The implementation in toolset_datadog_traces.py aligns with the rest of the codebase; no change is needed here.

Likely an incorrect or invalid review comment.

Comment thread holmes/plugins/toolsets/datadog/toolset_datadog_traces.py
Comment thread holmes/plugins/toolsets/datadog/toolset_datadog_traces.py
Comment thread holmes/plugins/toolsets/datadog/toolset_datadog_traces.py
Comment thread holmes/plugins/toolsets/datadog/toolset_datadog_traces.py
Comment thread holmes/plugins/toolsets/logging_utils/logging_api.py
aantn
aantn previously approved these changes Jul 21, 2025

@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

🧹 Nitpick comments (2)
tests/plugins/toolsets/datadog/traces/test_datadog_traces.py (2)

253-253: Fix the Yoda condition for better readability.

The test logic is correct, but the assertion uses a Yoda condition which should be reversed for conventional style.

-        assert "DataDog: fetch trace details for ID abc123" == one_liner
+        assert one_liner == "DataDog: fetch trace details for ID abc123"

342-342: Fix the Yoda condition for better readability.

The test logic is correct, but the assertion uses a Yoda condition which should be reversed for conventional style.

-        assert "DataDog: search spans with query: @http.status_code:500" == one_liner
+        assert one_liner == "DataDog: search spans with query: @http.status_code:500"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a3de564 and 34b8bc2.

📒 Files selected for processing (1)
  • tests/plugins/toolsets/datadog/traces/test_datadog_traces.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
tests/plugins/toolsets/datadog/traces/test_datadog_traces.py

253-253: Yoda condition detected

(SIM300)


342-342: Yoda condition detected

(SIM300)

⏰ 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). (7)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.11)
  • GitHub Check: llm_evals
🔇 Additional comments (1)
tests/plugins/toolsets/datadog/traces/test_datadog_traces.py (1)

253-253: Well-implemented test updates for logger name prefixing.

The test assertions have been correctly updated to reflect the new "DataDog: " prefix functionality. The changes are minimal, focused, and align well with the described feature enhancement for better log source identification.

Also applies to: 342-342

@arikalon1
arikalon1 enabled auto-merge (squash) July 21, 2025 20:43
@aantn
aantn disabled auto-merge July 22, 2025 07:06
@aantn
aantn enabled auto-merge (squash) July 22, 2025 07:06
@aantn
aantn merged commit c484c01 into master Jul 22, 2025
@aantn
aantn deleted the named-logging-calls branch July 22, 2025 07:14
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