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(metrics): get recurringjob label from status field instead of to… #3216

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

YvanGuidoin
Copy link
Contributor

@YvanGuidoin YvanGuidoin commented Oct 16, 2024

Which issue(s) this PR fixes:

Correcting implementation issue on #3034

Issue longhorn/longhorn#9429 (comment)

What this PR does / why we need it:

After testing from @longhorn/qa I corrected the source of label data to the one set in the test results

Special notes for your reviewer:

N/A

Additional documentation or context

N/A

Copy link

coderabbitai bot commented Oct 16, 2024

📝 Walkthrough

Walkthrough

The changes involve a modification to the Collect method in the BackupCollector struct located in the metrics_collector/backup_collector.go file. The source of the backupRecurringJobName variable has been updated from backup.Labels[types.RecurringJobLabel] to backup.Status.Labels[types.RecurringJobLabel]. This change affects the context from which the recurring job name is derived while leaving the rest of the method's logic, including error handling and metric collection, intact.

Changes

File Path Change Summary
metrics_collector/backup_collector.go Modified the source of backupRecurringJobName from backup.Labels to backup.Status.Labels.

Sequence Diagram(s)

sequenceDiagram
    participant BackupCollector
    participant Backup
    participant Metrics

    BackupCollector->>Backup: Collect()
    Backup->>BackupCollector: Retrieve Status.Labels
    BackupCollector->>Metrics: Collect metrics using Status.Labels
Loading

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d89ca20 and 8e22cd8.

📒 Files selected for processing (1)
  • metrics_collector/backup_collector.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • metrics_collector/backup_collector.go

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>, 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 resolve resolve all the CodeRabbit review comments.
  • @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.

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.

@YvanGuidoin YvanGuidoin force-pushed the backup_metrics_label_job branch 2 times, most recently from 4bb0d22 to d89ca20 Compare October 16, 2024 17:33
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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
metrics_collector/backup_collector.go (1)

82-82: Approved: Label retrieval change looks good. Consider adding error handling.

The change from backup.Labels to backup.Status.Labels for retrieving the recurring job name aligns with the PR objectives and addresses the issues mentioned in PR #3034 and issue #9429. This modification should improve the accuracy of the metrics collected for backups.

Consider adding error handling for cases where the label might not exist:

-backupRecurringJobName := backup.Status.Labels[types.RecurringJobLabel]
+backupRecurringJobName, ok := backup.Status.Labels[types.RecurringJobLabel]
+if !ok {
+    bc.logger.Warn("Recurring job label not found in backup status")
+}

This addition would make the code more robust and provide useful logging for debugging purposes.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8387bcf and d89ca20.

📒 Files selected for processing (1)
  • metrics_collector/backup_collector.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
metrics_collector/backup_collector.go (1)

82-84: Verify metrics reporting and consider additional testing.

While the change looks good, it's important to ensure that the metrics are correctly reported with this modification.

Please run the following script to check if the metrics are still being reported correctly:

Additionally, consider adding or updating unit tests to cover this change in label retrieval.

Copy link
Member

@derekbit derekbit left a comment

Choose a reason for hiding this comment

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

LGTM

@derekbit
Copy link
Member

derekbit commented Oct 21, 2024

@YvanGuidoin Could you create a BUG ticket for the fix? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants