Skip to content

Fix: #46 Inode Usage metrics #56

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

Merged
merged 3 commits into from
Mar 26, 2025

Conversation

noodlewhale
Copy link
Contributor

@noodlewhale noodlewhale commented Mar 23, 2025

added inode usage metrics as part of the disk metrics.

Summary by CodeRabbit

  • New Features
    • Enhanced disk metric reporting with additional insights. End-users will now see more detailed information, including used disk space in bytes and inode statistics (total, free, used counts, and usage percentage), offering a more comprehensive view of disk health.

Copy link
Contributor

coderabbitai bot commented Mar 23, 2025

Walkthrough

The changes extend disk metrics collection by enhancing the DiskData structures in both internal/metric/disk.go and internal/metric/metric.go. New fields related to inode metrics—UsedBytes, TotalInodes, FreeInodes, UsedInodes, and InodesUsagePercent—have been added. The CollectDiskMetrics function is updated to populate these fields from the disk usage data, thereby providing a more detailed representation of disk resource utilization.

Changes

Files Change Summary
internal/metric/disk.go, internal/metric/metric.go Enhanced DiskData by adding inode metric fields (UsedBytes, TotalInodes, FreeInodes, UsedInodes, InodesUsagePercent); updated CollectDiskMetrics to assign new values.

Sequence Diagram(s)

sequenceDiagram
    participant CM as CollectDiskMetrics
    participant DU as DiskUsage
    participant DD as DiskData

    CM->>DU: Retrieve disk usage metrics (bytes, inodes)
    DU-->>CM: Return disk usage data
    CM->>DD: Set fields:\nUsedBytes, TotalInodes, FreeInodes, UsedInodes,\nInodesUsagePercent (using RoundFloatPtr)
Loading

Possibly related PRs

  • Feat: Current Read/Write Data #54: The changes in the main PR and the retrieved PR are related as both modify the DiskData struct in internal/metric/metric.go to add new fields for tracking disk metrics, although they focus on different aspects of disk usage.

Suggested labels

enhancement

Poem

I'm a bunny of code with a happy heart,
Hopping through metrics, playing my part.
New inode fields sprout like carrots in spring,
Bytes and inodes together now sing.
With joyful hops, I celebrate the art! 🐰


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 934b0ef and d9f115c.

📒 Files selected for processing (2)
  • internal/metric/disk.go (2 hunks)
  • internal/metric/metric.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/metric/metric.go
🧰 Additional context used
🧬 Code Definitions (1)
internal/metric/disk.go (1)
internal/metric/metric_math.go (1)
  • RoundFloatPtr (11-14)
🔇 Additional comments (3)
internal/metric/disk.go (3)

13-26: Excellent addition of inode metrics to default DiskData structure.

The default initialization now includes the new inode-related fields with null pointers, which is consistent with other metrics in this structure and ensures backward compatibility when disk data cannot be collected.


75-75: Good addition of UsedBytes field.

This change complements the existing TotalBytes and FreeBytes fields, providing a complete picture of disk space utilization.


83-87: Properly implemented inode metrics collection.

The implementation correctly captures all inode-related metrics from the diskUsage structure. The use of RoundFloatPtr for InodesUsagePercent with division by 100 follows the same pattern used for UsagePercent, ensuring consistent normalization of percentage values to the range of 0-1.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

🧹 Nitpick comments (1)
internal/metric/disk.go (1)

82-95: Consider removing commented code

There's a commented-out function (CollectDiskMetricsTrial) at the end of the file. While it's not related to the current changes, consider removing it in a future PR to improve code cleanliness if it's no longer needed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 472e7be and 1a662cb.

📒 Files selected for processing (2)
  • internal/metric/disk.go (2 hunks)
  • internal/metric/metric.go (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
internal/metric/disk.go (1)
internal/metric/metric_math.go (1)
  • RoundFloatPtr (11-14)
🔇 Additional comments (3)
internal/metric/metric.go (1)

55-61: Good addition of inode metrics to DiskData

The new fields for tracking inode usage are a valuable enhancement to the disk metrics. This will help detect scenarios where a filesystem might run out of inodes even when there's available disk space. The fields are properly defined as pointers (consistent with existing fields), well-documented with clear comments, and have appropriate JSON tags.

internal/metric/disk.go (2)

16-22: Proper initialization of new disk data fields

The initialization of the new fields with nil values in the default disk data is consistent with the existing pattern. This ensures that when metrics cannot be collected, the API returns a consistent structure.


60-67: Good implementation of inode metrics collection

The population of the new fields from the diskUsage structure is implemented correctly. The usage of RoundFloatPtr for the percentage values ensures consistent formatting with 4 decimal places. The division by 100 for the percentage fields is also consistent with how the existing UsagePercent field is handled.

@mertssmnoglu mertssmnoglu added the enhancement New feature or request label Mar 26, 2025
@mertssmnoglu mertssmnoglu linked an issue Mar 26, 2025 that may be closed by this pull request
Copy link
Member

@mertssmnoglu mertssmnoglu left a comment

Choose a reason for hiding this comment

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

Hi @noodlewhale, thanks for your contribution. Very nice to see new 👋 faces here.

LGTM.

@mertssmnoglu mertssmnoglu merged commit ef5b236 into bluewave-labs:develop Mar 26, 2025
2 checks passed
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.

Metrics - Disk | Inode Usage
2 participants