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

fix: remove path label for cache store #4336

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

sunng87
Copy link
Member

@sunng87 sunng87 commented Jul 10, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

This patch fixes high cardinality on path label of opendal metrics. It's an issue introduce in #4277 . Because our file system cache shares same also uses this api, we get fragmented path label due to those usage. This path turns off path label for the cache.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • Refactor
    • Renamed new_fs_object_store to new_fs_cache_store and adjusted its implementation to include additional instrumentation.

@sunng87 sunng87 requested review from evenyag, v0y4g3r, waynexia and a team as code owners July 10, 2024 13:35
Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Walkthrough

The changes primarily revolve around enhancing the PrometheusMetricsLayer by adding a path_label boolean parameter to its instantiation, affecting how metrics are recorded. This modification propagates through various functions and modules, introducing minor adjustments to function signatures and refactoring specific function calls to accommodate the new parameter. These updates aim to improve the flexibility and granularity of metric labeling within the object store system.

Changes

File/Path Change Summary
...common/datasource/src/object_store/fs.rs Updated build_fs_backend to include new(true) call for PrometheusMetricsLayer.
...common/datasource/src/object_store/s3.rs Modified build_s3_backend to use PrometheusMetricsLayer::new(true).
src/datanode/src/store.rs Added a true parameter to the with_instrument_layers function call in new_object_store.
src/mito2/src/access_layer.rs Renamed new_fs_object_store to new_fs_store and introduced new_fs_cache_store with additional instrumentation.
src/mito2/src/cache/write_cache.rs Updated calls from new_fs_object_store to new_fs_cache_store within WriteCache implementation.
src/object-store/src/layers/prometheus.rs Introduced path_label field in PrometheusMetricsLayer and PrometheusAccess, adding methods to handle it.
src/object-store/src/util.rs with_instrument_layers function now takes an additional path_label parameter.
...mito2/src/sst/index/intermediate.rs Updated function call from new_fs_object_store to new_fs_cache_store in IntermediateManager.

Poem

In code's deep forest, metrics bloom anew,
With paths now labeled, insights shine through.
Object stores adapted, layers refined,
Prometheus whispers, "Data's aligned."
A rabbit hops through lines so bright,
Metrics in place, all set right. 🌟🐇


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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

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

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jul 10, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between da0c840 and 0d12f95.

Files selected for processing (7)
  • src/common/datasource/src/object_store/fs.rs (1 hunks)
  • src/common/datasource/src/object_store/s3.rs (1 hunks)
  • src/datanode/src/store.rs (1 hunks)
  • src/mito2/src/access_layer.rs (1 hunks)
  • src/mito2/src/cache/write_cache.rs (2 hunks)
  • src/object-store/src/layers/prometheus.rs (16 hunks)
  • src/object-store/src/util.rs (2 hunks)
Additional comments not posted (15)
src/common/datasource/src/object_store/fs.rs (1)

34-34: Ensure proper instantiation of PrometheusMetricsLayer.

The PrometheusMetricsLayer is instantiated with the new method and a true argument. This change seems correct and consistent with the objective of adding a path_label parameter.

Action Required: Verify that the boolean argument (true) is intended and correctly aligns with the desired behavior for the path_label.

Verification successful

Verified: Proper instantiation of PrometheusMetricsLayer.

The boolean argument true correctly aligns with the desired behavior for the path_label parameter in the PrometheusMetricsLayer::new method.

  • src/common/datasource/src/object_store/s3.rs
  • src/common/datasource/src/object_store/fs.rs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PrometheusMetricsLayer::new(true)` to ensure correctness.

# Test: Search for the usage of `PrometheusMetricsLayer::new` to confirm that the boolean argument is intended.
rg --type rust 'PrometheusMetricsLayer::new'

Length of output: 363


Script:

#!/bin/bash
# Search for the definition of the `PrometheusMetricsLayer::new` method to inspect its implementation.
ast-grep --lang rust --pattern 'impl PrometheusMetricsLayer { fn new($_) { $$$ } }'

Length of output: 85


Script:

#!/bin/bash
# Search for the definition of the `PrometheusMetricsLayer` struct or class to locate its implementation.
rg --type rust 'struct PrometheusMetricsLayer'

Length of output: 126


Script:

#!/bin/bash
# Search for the `new` method within the `src/object-store/src/layers/prometheus.rs` file.
rg 'fn new' src/object-store/src/layers/prometheus.rs -A 10

Length of output: 661

src/common/datasource/src/object_store/s3.rs (1)

97-97: Ensure proper instantiation of PrometheusMetricsLayer.

The PrometheusMetricsLayer is instantiated with the new method and a true argument. This change seems correct and consistent with the objective of adding a path_label parameter.

Action Required: Verify that the boolean argument (true) is intended and correctly aligns with the desired behavior for the path_label.

Verification successful

Proper instantiation of PrometheusMetricsLayer verified.

The boolean argument true in PrometheusMetricsLayer::new(true) correctly initializes the path_label field, ensuring the desired behavior.

  • src/common/datasource/src/object_store/s3.rs
  • src/common/datasource/src/object_store/fs.rs
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PrometheusMetricsLayer::new(true)` to ensure correctness.

# Test: Search for the usage of `PrometheusMetricsLayer::new` to confirm that the boolean argument is intended.
rg --type rust 'PrometheusMetricsLayer::new'

Length of output: 363


Script:

#!/bin/bash
# Description: Search for the definition of the `PrometheusMetricsLayer::new` method to understand the role of the boolean parameter.

# Locate the definition of `PrometheusMetricsLayer::new`.
rg --type rust 'fn new' | rg 'PrometheusMetricsLayer'

Length of output: 53


Script:

#!/bin/bash
# Description: Search for all occurrences of `PrometheusMetricsLayer` to locate its definition and understand the role of the boolean parameter.

# Search for any mention of `PrometheusMetricsLayer` to trace its definition.
rg --type rust 'PrometheusMetricsLayer'

Length of output: 751


Script:

#!/bin/bash
# Description: Inspect the implementation of `PrometheusMetricsLayer` in `src/object-store/src/layers/prometheus.rs` to find the `new` method and understand the boolean parameter.

# Search for the new method implementation within prometheus.rs
rg --type rust 'fn new' src/object-store/src/layers/prometheus.rs

Length of output: 122


Script:

#!/bin/bash
# Description: Inspect the surrounding code and comments in `src/object-store/src/layers/prometheus.rs` to understand the role of `path_label` in the `new` method.

# Display the surrounding lines of the `new` method implementation.
rg --type rust -A 10 -B 10 'fn new' src/object-store/src/layers/prometheus.rs

Length of output: 1173

src/datanode/src/store.rs (1)

63-63: Ensure correct usage of with_instrument_layers.

The with_instrument_layers function is called with an additional boolean argument (true). This change seems correct and consistent with the objective of adding a path_label parameter to the PrometheusMetricsLayer.

Action Required: Verify that the boolean argument (true) is intended and correctly aligns with the desired behavior for the path_label.

Verification successful

Usage of with_instrument_layers is correct.

The boolean argument (true) passed to with_instrument_layers is intended and correctly aligns with the desired behavior for the PrometheusMetricsLayer.

  • src/object-store/src/util.rs: The path_label parameter is used to initialize the PrometheusMetricsLayer.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `with_instrument_layers` with the additional boolean argument to ensure correctness.

# Test: Search for the usage of `with_instrument_layers` to confirm that the boolean argument is intended.
rg --type rust 'with_instrument_layers'

Length of output: 626


Script:

#!/bin/bash
# Retrieve the implementation details of the `with_instrument_layers` function
ast-grep --lang rust --pattern 'pub fn with_instrument_layers($_, $_) -> $_ { $$$ }'

Length of output: 1056


Script:

#!/bin/bash
# Retrieve the implementation details of the `PrometheusMetricsLayer::new` function
ast-grep --lang rust --pattern 'impl PrometheusMetricsLayer { pub fn new($_) -> $_ { $$$ } }'

Length of output: 439

src/object-store/src/util.rs (2)

141-141: Ensure proper instantiation of PrometheusMetricsLayer.

The PrometheusMetricsLayer is instantiated with the new method and a path_label argument. This change seems correct and consistent with the objective of adding a path_label parameter.

Action Required: Verify that the path_label argument is correctly passed and aligns with the desired behavior for the PrometheusMetricsLayer.

Verification successful

Verification Successful: Proper instantiation of PrometheusMetricsLayer

The PrometheusMetricsLayer is instantiated with the correct path_label argument in all instances.

  • src/object-store/src/util.rs
  • src/mito2/src/access_layer.rs
  • src/datanode/src/store.rs

The path_label argument is correctly passed and aligns with the desired behavior for the PrometheusMetricsLayer.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PrometheusMetricsLayer::new(path_label)` to ensure correctness.

# Test: Search for the usage of `PrometheusMetricsLayer::new` to confirm that the `path_label` argument is correctly passed.
rg --type rust 'PrometheusMetricsLayer::new'

Length of output: 363


Script:

#!/bin/bash
# Extract the surrounding lines in src/object-store/src/util.rs to verify the context of `PrometheusMetricsLayer::new(path_label)`
rg --type rust -A 5 -B 5 'PrometheusMetricsLayer::new\(path_label\)' src/object-store/src/util.rs

Length of output: 467


Script:

#!/bin/bash
# Extract the full definition of the `with_instrument_layers` function from src/object-store/src/util.rs
ast-grep --lang rust --pattern 'pub fn with_instrument_layers($_, $_) -> $_ { $$$ }'

# Search for invocations of the `with_instrument_layers` function within the codebase
rg --type rust 'with_instrument_layers'

Length of output: 1683


151-151: Ensure proper layering of PrometheusMetricsLayer.

The PrometheusMetricsLayer is added to the ObjectStore with the path_label parameter. This change seems correct and consistent with the objective of adding a path_label parameter.

Action Required: Verify that the PrometheusMetricsLayer is correctly layered and aligns with the desired behavior for the PrometheusMetricsLayer.

Verification successful

Verified: The PrometheusMetricsLayer is correctly layered and aligns with the desired behavior.

  • Implementation and usage of PrometheusMetricsLayer are consistent and correct across different files (fs.rs, s3.rs, and util.rs).
  • The path_label parameter is used appropriately.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the layering of `PrometheusMetricsLayer` to ensure correctness.

# Test: Search for the usage of `PrometheusMetricsLayer` in layering to confirm that it is correctly layered.
rg --type rust 'PrometheusMetricsLayer'

Length of output: 751


Script:

#!/bin/bash
# Extract the implementation of PrometheusMetricsLayer from src/object-store/src/layers/prometheus.rs
echo "Implementation of PrometheusMetricsLayer in src/object-store/src/layers/prometheus.rs:"
rg --type rust -A 10 'pub struct PrometheusMetricsLayer' src/object-store/src/layers/prometheus.rs

# Extract the context of usage in src/common/datasource/src/object_store/fs.rs
echo -e "\nUsage in src/common/datasource/src/object_store/fs.rs:"
rg --type rust -A 10 '.layer\(object_store::layers::PrometheusMetricsLayer::new\(true\)\)' src/common/datasource/src/object_store/fs.rs

# Extract the context of usage in src/common/datasource/src/object_store/s3.rs
echo -e "\nUsage in src/common/datasource/src/object_store/s3.rs:"
rg --type rust -A 10 '.layer\(object_store::layers::PrometheusMetricsLayer::new\(true\)\)' src/common/datasource/src/object_store/s3.rs

# Extract the context of usage in src/object-store/src/util.rs
echo -e "\nUsage in src/object-store/src/util.rs:"
rg --type rust -A 10 '.layer\(PrometheusMetricsLayer::new\(path_label\)\)' src/object-store/src/util.rs

Length of output: 1868

src/mito2/src/access_layer.rs (3)

211-218: LGTM!

The code changes correctly handle the path_label parameter in the new_fs_store function.


220-223: LGTM!

The code changes correctly handle the path_label parameter in the new_fs_object_store function.


225-227: LGTM!

The new function new_fs_cache_store correctly sets the path_label parameter to false.

src/mito2/src/cache/write_cache.rs (1)

Line range hint 89-97: LGTM!

The code changes correctly use the new_fs_cache_store function to create the local store in the new_fs function.

src/object-store/src/layers/prometheus.rs (6)

87-89: LGTM!

The addition of the path_label field to the PrometheusMetricsLayer struct is correct.


91-95: LGTM!

The new method correctly initializes the PrometheusMetricsLayer struct with the path_label parameter.


115-117: LGTM!

The addition of the path_label field to the PrometheusAccess struct is correct.


119-126: LGTM!

The get_path_label method correctly handles the path_label logic based on the value of the path_label field.


Line range hint 97-107: LGTM!

The layer method correctly includes the path_label field when creating a PrometheusAccess.


Line range hint 151-478: LGTM!

The methods in PrometheusAccess correctly use the get_path_label method to handle the path_label logic.

@sunng87
Copy link
Member Author

sunng87 commented Jul 10, 2024

@evenyag not sure if we want to turn off path label for IntermediateManager as well.

edit: confirmed we need to do that

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 84.90%. Comparing base (da0c840) to head (b7cb522).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4336      +/-   ##
==========================================
- Coverage   85.18%   84.90%   -0.28%     
==========================================
  Files        1060     1060              
  Lines      189069   189076       +7     
==========================================
- Hits       161057   160535     -522     
- Misses      28012    28541     +529     

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0d12f95 and 059c883.

Files selected for processing (1)
  • src/mito2/src/sst/index/intermediate.rs (2 hunks)
Additional comments not posted (1)
src/mito2/src/sst/index/intermediate.rs (1)

22-23: LGTM! The use of new_fs_cache_store aligns with the PR objectives.

The function init_fs now correctly uses new_fs_cache_store to disable the path label for the cache, addressing the high cardinality issue.

Also applies to: 40-41

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 059c883 and 9025573.

Files selected for processing (2)
  • src/mito2/src/access_layer.rs (1 hunks)
  • src/mito2/src/sst/index/intermediate.rs (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/mito2/src/access_layer.rs
  • src/mito2/src/sst/index/intermediate.rs

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9025573 and b7cb522.

Files selected for processing (1)
  • src/mito2/src/access_layer.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/mito2/src/access_layer.rs

Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

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

LGTM

@fengjiachun fengjiachun added this pull request to the merge queue Jul 15, 2024
Merged via the queue into GreptimeTeam:main with commit b8bd845 Jul 15, 2024
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants