-
Notifications
You must be signed in to change notification settings - Fork 92
Added metrics - object count, max_objects and max_size for quota #9205
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
Conversation
WalkthroughAdds per-bucket object count and quota limit metrics to Prometheus reporting and surfaces quota caps and object counts in bucket stats via a new helper in stats_aggregator; Prometheus gauges are reset and set per-bucket for these new fields. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant SA as StatsAggregator
participant QH as _get_bucket_quota_info
participant PR as PrometheusReport
rect rgba(230,245,255,0.6)
note over SA,QH: Compute quota usage percentages and caps
SA->>QH: request quota usages & caps (bucket)
QH-->>SA: size_used%, quantity_used%, quota_max_bytes, quota_max_objects
SA-->>SA: include quota_max_* and object_count in bucket payload
end
rect rgba(235,255,235,0.6)
note over PR: Reset and set per-bucket Prometheus gauges
PR->>PR: reset bucket_object_count, bucket_max_objects_quota, bucket_max_bytes_quota
PR->>PR: set bucket_object_count[bucket_name] = object_count
PR->>PR: set bucket_max_objects_quota[bucket_name] = quota_max_objects
PR->>PR: set bucket_max_bytes_quota[bucket_name] = quota_max_bytes
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ 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). (3)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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. Comment |
There was a problem hiding this 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
🧹 Nitpick comments (3)
src/server/system_services/stats_aggregator.js (2)
421-433: Deduplicate quota getter calls; keep numeric conversion explicit and cheap.Avoid calling get_quota_by_size/quantity twice and prefer a single parse step. Functionality unchanged, a bit cleaner and marginally faster.
- const { size_used_percent, quantity_used_percent } = quota.get_bucket_quota_usages_percent(bucket); - const quota_max_objects = quota.get_quota_by_quantity() === '0' ? 0 : parseInt(quota.get_quota_by_quantity(), 10); - const quota_max_bytes = quota.get_quota_by_size() === '0' ? 0 : size_utils.json_to_bigint(quota.get_quota_by_size()).toJSNumber(); + const { size_used_percent, quantity_used_percent } = quota.get_bucket_quota_usages_percent(bucket); + const quantity_raw = quota.get_quota_by_quantity(); + const size_raw = quota.get_quota_by_size(); + const quota_max_objects = quantity_raw === '0' ? 0 : Number(quantity_raw); + const quota_max_bytes = size_raw === '0' ? 0 : size_utils.json_to_bigint(size_raw).toJSNumber();
530-543: Make bucket_used_bytes conversion explicit (and resilient).valueOf() relies on implicit coercion. Use toJSNumber() for consistency with the rest of this file and guard if storage_stats is missing.
- bucket_used_bytes: bucket_used.valueOf(), + bucket_used_bytes: bucket_used ? bucket_used.toJSNumber() : 0,src/server/analytic_services/prometheus_reports/noobaa_core_report.js (1)
311-325: Clarify metric help strings (units and unlimited semantics).Make it obvious that 0 means “unlimited”, and specify units for bytes.
- configuration: { - help: 'Bucket Maximum Objects Quota', + configuration: { + help: 'Bucket Maximum Objects Quota (0 = unlimited)', labelNames: ['bucket_name'] } }, { type: 'Gauge', name: 'bucket_max_bytes_quota', configuration: { - help: 'Bucket Maximum Bytes Quota', + help: 'Bucket Maximum Bytes Quota (bytes; 0 = unlimited)', labelNames: ['bucket_name'] }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/server/analytic_services/prometheus_reports/noobaa_core_report.js(3 hunks)src/server/system_services/stats_aggregator.js(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/server/analytic_services/prometheus_reports/noobaa_core_report.js (1)
src/server/system_services/stats_aggregator.js (1)
bucket_info(461-461)
src/server/system_services/stats_aggregator.js (1)
src/server/system_services/bucket_server.js (23)
bucket(343-343)bucket(357-357)bucket(376-376)bucket(394-394)bucket(419-419)bucket(431-431)bucket(446-446)bucket(482-482)bucket(491-491)bucket(504-504)bucket(513-513)bucket(539-539)bucket(558-558)bucket(572-572)bucket(590-590)bucket(604-604)quota(753-753)quota(862-862)quota(1617-1617)quota(1676-1676)Quota(39-39)size_utils(21-21)bucket_used(1651-1651)
⏰ 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). (3)
- GitHub Check: Build Noobaa Image
- GitHub Check: run-jest-unit-tests
- GitHub Check: run-package-lock-validation
🔇 Additional comments (2)
src/server/analytic_services/prometheus_reports/noobaa_core_report.js (2)
580-582: Resetting new gauges is correct.Ensures no stale series remain between scrapes. LGTM.
593-595: Use nullish coalescing for quota defaultsReplace
|| 0with?? 0so onlynull/undefinedfall back, not all falsy values:- this._metrics.bucket_max_objects_quota.set({ bucket_name: bucket_info.bucket_name }, bucket_info.quota_max_objects || 0); - this._metrics.bucket_max_bytes_quota.set({ bucket_name: bucket_info.bucket_name }, bucket_info.quota_max_bytes || 0); + this._metrics.bucket_max_objects_quota.set({ bucket_name: bucket_info.bucket_name }, bucket_info.quota_max_objects ?? 0); + this._metrics.bucket_max_bytes_quota.set({ bucket_name: bucket_info.bucket_name }, bucket_info.quota_max_bytes ?? 0);Please verify these gauges are exposed correctly at runtime.
1a4750f to
94d3da8
Compare
…t_max_size_quota for quota Signed-off-by: Aayush Chouhan <[email protected]>
94d3da8 to
0e4f273
Compare
Describe the Problem
Currently, we have not exposed any metrics to show current object, max objects and max size set for bucket in quota.
Explain the Changes
bucket_object_count,bucket_max_objects_quotaandbucket_max_bytes_quota.Issues: Fixed #xxx / Gap #xxx
Testing Instructions:
Summary by CodeRabbit