Repository navigation
feat: report storage type and storage mode [backport #959] - #960
Conversation
Report the storage type (local or s3) and storage mode (cdc or whole) in public analytics and internal metrics. (cherry picked from commit 5f72e8b)
Summary of ChangesHello @kalbasit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces new attributes to the system's public analytics and internal metrics, specifically detailing the storage type and mode in use. This enhancement provides valuable operational insights into how the system is deployed and configured, aiding in monitoring and troubleshooting efforts without altering core functionality. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds analytics attributes for storage type (local or s3) and storage mode (cdc or whole). The changes correctly detect these configurations and update the analytics documentation. The implementation is straightforward and looks correct. I have one suggestion to improve maintainability by replacing magic strings with constants, following the existing pattern in the file, which aligns with the project's consistency rule.
| if localDataPath != "" { | ||
| attrs = append(attrs, attribute.String("ncps.storage_type", "local")) | ||
| } else if s3Cfg != nil { | ||
| attrs = append(attrs, attribute.String("ncps.storage_type", "s3")) | ||
| } | ||
|
|
||
| // 5. Add storage mode | ||
| if cmd.Bool("cache-cdc-enabled") { | ||
| attrs = append(attrs, attribute.String("ncps.storage_mode", "cdc")) | ||
| } else { | ||
| attrs = append(attrs, attribute.String("ncps.storage_mode", "whole")) | ||
| } |
There was a problem hiding this comment.
To improve maintainability and avoid magic strings, it's a good practice to define constants for attribute values like "local", "s3", "cdc", and "whole". You can define them at the file level, similar to lockBackendLocal and lockBackendRedis.
For example, you could add these constants near the top of the file:
const (
storageTypeLocal = "local"
storageTypeS3 = "s3"
storageModeCDC = "cdc"
storageModeWhole = "whole"
)And then use them in this function:
if localDataPath != "" {
attrs = append(attrs, attribute.String("ncps.storage_type", storageTypeLocal))
} else if s3Cfg != nil {
attrs = append(attrs, attribute.String("ncps.storage_type", storageTypeS3))
}
// 5. Add storage mode
if cmd.Bool("cache-cdc-enabled") {
attrs = append(attrs, attribute.String("ncps.storage_mode", storageModeCDC))
} else {
attrs = append(attrs, attribute.String("ncps.storage_mode", storageModeWhole))
}References
- Prioritize consistency with existing code patterns within the project over adopting alternative patterns, even if those alternatives are also valid. This comment suggests defining constants for magic strings, following the existing pattern of
lockBackendLocalandlockBackendRediswithin the file.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-0.9 #960 +/- ##
===========================================
Coverage 5.04% 5.04%
===========================================
Files 6 6
Lines 436 436
===========================================
Hits 22 22
Misses 410 410
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bot-based backport to
release-0.9, triggered by a label in #959.Report the storage type (local or s3) and storage mode (cdc or whole) in
public analytics and internal metrics.