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(new_metrics): support server_stat command showing some important server-level metrics (part 1) #2085

Merged
merged 14 commits into from
Aug 23, 2024

Conversation

empiredan
Copy link
Contributor

@empiredan empiredan commented Aug 1, 2024

As the 1st part that support server_stat command, both built-in metrics, the usage
of virtual and physical memory would be shown.

@github-actions github-actions bot added the cpp label Aug 1, 2024
@empiredan empiredan changed the title New metrics server stat mem feat(new_metrics): support server_stat command (part 1) Aug 1, 2024
@empiredan empiredan marked this pull request as ready for review August 2, 2024 09:57
@empiredan empiredan added the component/shell pegasus shell label Aug 2, 2024
// Adapt the result returned by `get_metrics` into the structure that could be processed by
// `remote_command`.
template <typename... Args>
inline std::pair<bool, std::string> process_get_metrics_result(const dsn::http_result &result,
Copy link
Member

Choose a reason for hiding this comment

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

It seems the return type can be replaced by error_s or absl::Status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, use error_s instead.

@@ -101,7 +101,7 @@ static command_executor commands[] = {
"get the node status for this cluster",
"[-d|--detailed] [-j|--json] [-r|--resolve_ip] [-u|--resource_usage] "
"[-o|--output file_name] [-s|--status all|alive|unalive] [-q|--qps] "
"[-t|--sample_interval_ms num]",
"[-i|--sample_interval_ms num]",
Copy link
Member

Choose a reason for hiding this comment

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

It should be mentioned in "Behavior changes" in the PR description for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, the options sample_interval_ms was introduced recently and never released before.

dsn::json::json_forwarder<meta_server_stats>::encode(stats).to_string());
}

struct replica_server_stats
Copy link
Member

Choose a reason for hiding this comment

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

It's the same to meta_server_stats, how about using a unify one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually they are different, since more metrics would be introduced later.

dsn::metric_filters filters;
filters.with_metric_fields = {dsn::kMetricNameField, dsn::kMetricSingleValueField};
filters.entity_types = {"server"};
filters.entity_metrics = {"virtual_mem_usage_mb", "resident_mem_usage_mb"};
Copy link
Member

Choose a reason for hiding this comment

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

What about defining some static const strings for these metric names?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These names of metrics have been defined, initialized and set as following statements, thus I think we could just keep them in the format of strings.

METRIC_DEFINE_gauge_int64(server,
                          virtual_mem_usage_mb,
                          dsn::metric_unit::kMegaBytes,
                          "The total amount of virtual memory usage in MB");

METRIC_VAR_INIT_server(virtual_mem_usage_mb)

METRIC_VAR_SET(virtual_mem_usage_mb, virt_mb);

@empiredan empiredan force-pushed the new-metrics-server-stat-mem branch from a70559b to b12d717 Compare August 21, 2024 09:46
@empiredan empiredan changed the title feat(new_metrics): support server_stat command (part 1) feat(new_metrics): support server_stat command to show some important server-level metrics (part 1) Aug 23, 2024
@empiredan empiredan changed the title feat(new_metrics): support server_stat command to show some important server-level metrics (part 1) feat(new_metrics): support server_stat command showing some important server-level metrics (part 1) Aug 23, 2024
@empiredan empiredan merged commit c99cfd6 into apache:master Aug 23, 2024
90 of 96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants