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

refactor: add slow query logging options #191

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

zyy17
Copy link
Collaborator

@zyy17 zyy17 commented Nov 5, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new logging configuration for slow queries, allowing users to enable and customize slow query logging with parameters for threshold and sample ratio.
  • Documentation
    • Updated version number in README and added detailed information about the new slow query logging configuration.
  • Chores
    • Incremented version number of the Helm chart from 0.2.25 to 0.2.26.

Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

Walkthrough

The changes involve an update to the greptimedb-cluster Helm chart, primarily reflected in the Chart.yaml, README.md, cluster.yaml, and values.yaml files. The version number is incremented from 0.2.25 to 0.2.26. Additionally, a new configuration option for slow query logging is introduced, allowing users to enable logging of slow queries with parameters for threshold and sample ratio. These modifications enhance the logging capabilities without altering existing functionalities.

Changes

File Path Change Summary
charts/greptimedb-cluster/Chart.yaml Version updated from 0.2.25 to 0.2.26.
charts/greptimedb-cluster/README.md Version updated from 0.2.25 to 0.2.26. Added logging.slowQuery configuration with parameters.
charts/greptimedb-cluster/templates/cluster.yaml Added conditional logging configuration for slow queries based on slowQuery.enabled.
charts/greptimedb-cluster/values.yaml Introduced new logging configuration for slow queries: enabled, threshold, and sampleRatio.

Possibly related PRs

Suggested reviewers

  • daviderli614

🐰 In the meadow, changes bloom,
A version bump dispels the gloom.
Slow queries now can be tracked,
With logging features, never lack!
Hopping forward, let’s embrace,
New capabilities in our space! 🌼


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 (4)
charts/greptimedb-cluster/templates/cluster.yaml (1)

488-493: LGTM! Consider adding value validation.

The slow query logging configuration is well-structured and properly integrated into the existing logging section. The implementation follows Helm best practices with proper conditional checks and consistent formatting.

Consider adding validation for the input values:

  1. Ensure the threshold format is valid (e.g., "10s", "1m")
  2. Verify sampleRatio is between 0 and 1

Example validation using Helm's required and fail functions:

    {{- if .Values.logging.slowQuery.enabled }}
    slowQuery:
      enabled: {{ .Values.logging.slowQuery.enabled }}
+     {{- if not (regexMatch "^[0-9]+(ns|us|ms|s|m|h)$" .Values.logging.slowQuery.threshold) }}
+     {{- fail "slowQuery.threshold must be a valid duration (e.g., 10s, 1m)" }}
+     {{- end }}
      threshold: {{ .Values.logging.slowQuery.threshold }}
+     {{- $ratio := float64 .Values.logging.slowQuery.sampleRatio }}
+     {{- if or (lt $ratio 0.0) (gt $ratio 1.0) }}
+     {{- fail "slowQuery.sampleRatio must be between 0 and 1" }}
+     {{- end }}
      sampleRatio: {{ .Values.logging.slowQuery.sampleRatio | quote }}
    {{- end }}
charts/greptimedb-cluster/values.yaml (2)

781-782: Consider adding units documentation for threshold.

While "10s" implies seconds, it would be helpful to explicitly document the supported duration units (e.g., "ms", "s", "m") in the comment.

-    # -- The threshold of slow query log in seconds.
+    # -- The threshold of slow query log. Supported units: ms, s, m (e.g., "100ms", "10s", "1m").

784-785: Consider adding validation range for sample ratio.

The comment should specify that the sample ratio must be between 0.0 and 1.0.

-    # -- Sample ratio of slow query log.
+    # -- Sample ratio of slow query log (must be between 0.0 and 1.0).
charts/greptimedb-cluster/README.md (1)

216-225: Documentation could be enhanced with parameter constraints.

The slow query logging configuration is well-documented, but consider adding:

  • Valid range for sampleRatio (e.g., 0.0 to 1.0)
  • Minimum/maximum values for threshold
 | logging.slowQuery | object | `{"enabled":false,"sampleRatio":"1.0","threshold":"10s"}` | The slow query log configuration. |
 | logging.slowQuery.enabled | bool | `false` | Enable slow query log. |
-| logging.slowQuery.sampleRatio | string | `"1.0"` | Sample ratio of slow query log. |
-| logging.slowQuery.threshold | string | `"10s"` | The threshold of slow query log in seconds. |
+| logging.slowQuery.sampleRatio | string | `"1.0"` | Sample ratio of slow query log (range: 0.0 to 1.0). |
+| logging.slowQuery.threshold | string | `"10s"` | The threshold of slow query log (minimum: 1s). |
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between af2e017 and 52a7fbb.

📒 Files selected for processing (4)
  • charts/greptimedb-cluster/Chart.yaml (1 hunks)
  • charts/greptimedb-cluster/README.md (2 hunks)
  • charts/greptimedb-cluster/templates/cluster.yaml (1 hunks)
  • charts/greptimedb-cluster/values.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • charts/greptimedb-cluster/Chart.yaml
🔇 Additional comments (2)
charts/greptimedb-cluster/values.yaml (1)

776-786: LGTM! Well-structured slow query logging configuration.

The new slow query logging configuration is well-organized and properly documented. The parameters are sensible with good default values:

  • enabled: false - Safe default that requires explicit opt-in
  • threshold: "10s" - Reasonable default threshold
  • sampleRatio: "1.0" - Full sampling by default

Let's verify the integration with Grafana dashboards since the configuration mentions a slow queries dashboard:

charts/greptimedb-cluster/README.md (1)

5-5: LGTM: Version update is consistent.

The version badge has been correctly updated to reflect the new version 0.2.26.

@zyy17 zyy17 enabled auto-merge (squash) November 5, 2024 10:54
@zyy17 zyy17 merged commit ad0e1aa into GreptimeTeam:main Nov 5, 2024
3 checks passed
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