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

feat: support cache in logs #4516

Merged
merged 11 commits into from
Feb 12, 2024
Merged

feat: support cache in logs #4516

merged 11 commits into from
Feb 12, 2024

Conversation

nityanandagohain
Copy link
Member

@nityanandagohain nityanandagohain commented Feb 8, 2024

Fixes #4513

Summary by CodeRabbit

  • New Features
    • Introduced caching for log queries to enhance performance.
    • Added functionality to handle log queries with various conditions and limits.
  • Refactor
    • Improved logic for preparing log queries with caching.
    • Enhanced key generation for log queries to include more detailed information.

@github-actions github-actions bot added the enhancement New feature or request label Feb 8, 2024
Copy link

coderabbitai bot commented Feb 8, 2024

Walkthrough

The recent updates introduce caching support for log queries in the query service, optimizing performance by reducing redundant data fetching. A new function, prepareLogsQuery, is central to these changes, streamlining the preparation of log queries with various conditions and limits. Additionally, the update includes enhancements in key generation for cache identification and a method to filter cached data points within specific time ranges, ensuring efficient data retrieval and processing.

Changes

Files Change Summaries
.../app/querier/helper.go - Added prepareLogsQuery for log query preparation
- Refactored runBuilderQuery to use new caching
.../app/querier/querier.go - Added comments on time.Now
- Added filterCachedPoints function
.../app/queryBuilder/query_builder.go - Updated isMetricExpression
- Enhanced GenerateKeys for log queries
.../model/v3/v3.go - Added CacheKey method in OrderBy struct

Assessment against linked issues

Objective Addressed Explanation
Add cache support in logs (#4513)

Poem

In the field where the Chiefs and Niners play,
A rabbit watched, dreaming of the fray.
"In the world of code, we dash and dive,
Adding cache to logs, making queries thrive.
🏈 Amidst the cheers and the Super Bowl's call,
We tackle bugs and leap over the wall.
Let's celebrate the game, with a hop and a cheer,
For every sprint and cache, the goal is near!"

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@nityanandagohain nityanandagohain marked this pull request as ready for review February 12, 2024 04:29
Copy link

@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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ab4f6ad and ba3e1ae.
Files selected for processing (4)
  • pkg/query-service/app/querier/helper.go (4 hunks)
  • pkg/query-service/app/querier/querier.go (2 hunks)
  • pkg/query-service/app/queryBuilder/query_builder.go (2 hunks)
  • pkg/query-service/model/v3/v3.go (1 hunks)
Additional comments: 5
pkg/query-service/app/queryBuilder/query_builder.go (2)
  • 298-298: The check in isMetricExpression now includes v3.DataSourceLogs. Ensure that this change aligns with the intended logic for identifying metric expressions, as it now treats log data sources similarly to metric data sources.
  • 323-362: In GenerateKeys, when generating cache keys for v3.DataSourceLogs, ensure that all relevant query attributes are included to guarantee the uniqueness of cache keys. Also, validate the logic for assembling parts into the final cache key string for correctness and efficiency.
pkg/query-service/app/querier/querier.go (2)
  • 163-164: The comment explaining the use of time.Now for considering data ingestion delays is clear. However, ensure that relying on time.Now does not introduce any issues with time synchronization or testing.
  • 246-257: The implementation of filterCachedPoints correctly filters points based on the timestamp. Ensure that this function is called in the appropriate context to apply the filtering to cached series data effectively.
pkg/query-service/model/v3/v3.go (1)
  • 820-822: The implementation of the CacheKey method in the OrderBy struct is correct and aligns with the caching strategy. It generates cache keys based on ColumnName and Order, which is suitable for caching purposes.

pkg/query-service/app/querier/helper.go Outdated Show resolved Hide resolved
pkg/query-service/app/querier/helper.go Outdated Show resolved Hide resolved
pkg/query-service/app/querier/helper.go Outdated Show resolved Hide resolved
Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ba3e1ae and 4d166a4.
Files selected for processing (1)
  • pkg/query-service/app/querier/helper.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • pkg/query-service/app/querier/helper.go

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4d166a4 and 0dc7453.
Files selected for processing (2)
  • pkg/query-service/app/querier/helper.go (4 hunks)
  • pkg/query-service/app/queryBuilder/query_builder.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • pkg/query-service/app/querier/helper.go
  • pkg/query-service/app/queryBuilder/query_builder.go

srikanthccv
srikanthccv previously approved these changes Feb 12, 2024
Copy link
Member

@srikanthccv srikanthccv left a comment

Choose a reason for hiding this comment

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

Please test various queries once. Are regular full text search also cached or only aggregation queries. I think it should only include aggregation queries.

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0dc7453 and 8ddcab9.
Files selected for processing (1)
  • pkg/query-service/app/querier/helper.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • pkg/query-service/app/querier/helper.go

@nityanandagohain
Copy link
Member Author

Yes it's only for aggreagte queries.

@nityanandagohain nityanandagohain merged commit 0e331dd into develop Feb 12, 2024
11 checks passed
@nityanandagohain nityanandagohain deleted the issue_4513 branch February 12, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LOGS[BE]: Add cache support
2 participants