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

refactor: Add metrics collector #4407

Merged
merged 26 commits into from
Jan 3, 2023
Merged

Conversation

bassmang
Copy link
Member

@bassmang bassmang commented Dec 29, 2022

NOTE
Remember to remove metric_output_hooks from RLClientlib when updading VW and replace with metrics_manager register_callback_function

vowpalwabbit/core/src/metrics_manager.cc Outdated Show resolved Hide resolved
vowpalwabbit/core/src/reductions/baseline_challenger_cb.cc Outdated Show resolved Hide resolved
vowpalwabbit/core/include/vw/core/learner.h Outdated Show resolved Hide resolved
vowpalwabbit/core/src/reductions/metrics.cc Outdated Show resolved Hide resolved
vowpalwabbit/core/src/reductions/metrics.cc Outdated Show resolved Hide resolved
vowpalwabbit/core/src/reductions/metrics.cc Outdated Show resolved Hide resolved
for (auto& metric_hook : all.metric_output_hooks) { metric_hook(list_metrics); }

list_metrics.set_uint("total_log_calls", all.logger.get_log_count());
auto additional_metrics = [&all](metric_sink& sink) -> void
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should add this extra stuff as a callback. That means if you were to call output_metrics twice it would add the callback twice.

I think we should leave the callbacks as is and add these extra metrics outside of being a callback.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree this should be decoupled from output_metrics. I think it will still need to be added as a callback, since there is no way to interact with the metrics_sink directly in the new design. I added a callback in parse_args so it will not be called multiple times (eg in output_metrics or list_to_json_file)

@olgavrou
Copy link
Collaborator

olgavrou commented Jan 3, 2023

what is the objective of metrics manager? to provide global information on whether metrics are enabled and to provide a way for collection of metrics to be called in lib mode? e.g. python can collect metrics now both by calling persist_metrics and collect_metrics?

using metrics_callback_fn = std::function<void(VW::metric_sink&)>;

bool are_metrics_enabled() const;
std::string get_filename() const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

get_filename should not be here if the class never uses it, it should probably still live in metrics, or are there plans for it to be used somehow in the future?

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted back to std::string filename = all.options->get_typed_option<std::string>("extra_metrics").value();


namespace VW
{
class metrics_manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we remove the filename this could be renamed to metrics_collector and restrict the object from potentially becoming another all object in the future

Copy link
Member Author

Choose a reason for hiding this comment

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

removed filename and updated to metics_collector

private:
bool _are_metrics_enabled;
std::vector<metrics_callback_fn> _metrics_callbacks;
std::string _metrics_filename;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
std::string _metrics_filename;

@bassmang bassmang changed the title refactor: Add metrics manager refactor: Add metrics collector Jan 3, 2023
@bassmang bassmang merged commit 9741c69 into VowpalWabbit:master Jan 3, 2023
@bassmang bassmang deleted the metrics_fix branch January 3, 2023 18:37
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.

3 participants