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

Feature: add Raft::data_metrics() and Raft::server_metrics() #990

Merged
merged 5 commits into from
Jan 14, 2024

Conversation

YangKian
Copy link
Contributor

@YangKian YangKian commented Jan 14, 2024

close #985


This change is Reviewable

@YangKian
Copy link
Contributor Author

@drmingdrmer Hi~ I'm done, PTAL when you have time

@drmingdrmer drmingdrmer self-requested a review January 14, 2024 05:27
Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

Thank you man.

The metrics producing process can be simplified:)

Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @YangKian)


openraft/src/metrics/mod.rs line 42 at r1 (raw file):

pub use metric::Metric;
pub use raft_metrics::is_data_metrics_changed;
pub use raft_metrics::is_server_metrics_changed;

I think these two functions can be removed since the spawned task I mentioned above is no necessary.


openraft/src/metrics/raft_metrics.rs line 174 at r1 (raw file):

where NID: NodeId
{
    pub last_log_index: Option<u64>,

OpenRaft prefers the use of LogId over log-index whenever possible.
RaftMetrics::last_log_index is kept for backward compatibility.
For this newly added field, use last_log: Option<LogId> instead.


openraft/src/metrics/raft_metrics.rs line 238 at r1 (raw file):

{
    pub id: NID,
    pub current_term: u64,

Openraft uses Vote instead of term when possible. current_term is kept in RaftMetrics for backward compatibility. In RaftServerMetrics, this field can be removed. An application can just use vote.leader_id.get_term() instead.


openraft/src/raft/mod.rs line 210 at r1 (raw file):

                }
            }
        });

you do not have to create another task to replicate the metrics to data-metrics and server-metrics.
Just do this in report_metrics, which is the only entry in Openraft to update metrics.

Copy link
Contributor Author

@YangKian YangKian left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 7 files reviewed, 4 unresolved discussions (waiting on @drmingdrmer)


openraft/src/metrics/mod.rs line 42 at r1 (raw file):

Previously, drmingdrmer (张炎泼) wrote…

I think these two functions can be removed since the spawned task I mentioned above is no necessary.

Done.


openraft/src/metrics/raft_metrics.rs line 174 at r1 (raw file):

Previously, drmingdrmer (张炎泼) wrote…

OpenRaft prefers the use of LogId over log-index whenever possible.
RaftMetrics::last_log_index is kept for backward compatibility.
For this newly added field, use last_log: Option<LogId> instead.

Done.


openraft/src/metrics/raft_metrics.rs line 238 at r1 (raw file):

Previously, drmingdrmer (张炎泼) wrote…

Openraft uses Vote instead of term when possible. current_term is kept in RaftMetrics for backward compatibility. In RaftServerMetrics, this field can be removed. An application can just use vote.leader_id.get_term() instead.

Done.


openraft/src/raft/mod.rs line 210 at r1 (raw file):

Previously, drmingdrmer (张炎泼) wrote…

you do not have to create another task to replicate the metrics to data-metrics and server-metrics.
Just do this in report_metrics, which is the only entry in Openraft to update metrics.

Done.

Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @YangKian)

@drmingdrmer drmingdrmer merged commit 8261589 into databendlabs:main Jan 14, 2024
27 checks passed
@YangKian YangKian deleted the metrics branch January 14, 2024 10:31
@drmingdrmer drmingdrmer mentioned this pull request Mar 9, 2024
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.

Split metrics into data metrics and server metrics
2 participants