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

Pull Admin module out of Metrics #220

Merged
merged 4 commits into from
Mar 29, 2021
Merged

Pull Admin module out of Metrics #220

merged 4 commits into from
Mar 29, 2021

Conversation

markmandel
Copy link
Member

This pulls the hyper server out of the Metrics module and move it into its own Admin module that handles metrics, and in the future, the health/liveness endpoint as well.

Closes #101

@markmandel markmandel added the kind/cleanup Refactoring code, fixing up documentation, etc label Mar 22, 2021
@markmandel markmandel requested a review from iffyio March 22, 2021 21:13
@google-cla google-cla bot added the cla: yes label Mar 22, 2021
src/proxy/metrics.rs Outdated Show resolved Hide resolved
src/test_utils.rs Outdated Show resolved Hide resolved
src/proxy/metrics.rs Outdated Show resolved Hide resolved
This pulls the `hyper` server out of the `Metrics` module and move it
into its own `Admin` module that handles metrics, and in the future, the
health/liveness endpoint as well.

Closes #101
src/proxy/builder.rs Outdated Show resolved Hide resolved
- Rename `admin_response` ➡ `collect_metrics`
- Move some `pub` crates to `pub(crate)`
- Refactor `test_util.rs` to align more with the builder pattern.
}

/// Create and run a server with the admin interface enabled.
pub fn run_server_with_admin(&mut self, config: Config) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be something like run_server_with_config? since admin's not particulary specific to the function (i.e there's other things that are enabled as well)

}

/// Create and run a server (no admin)
fn run_server_with_arguments(&mut self, config: Config, filter_registry: FilterRegistry) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm finding this function signature a bit confusing, currently run_server_with_admin(config) enables admin while run_server_with_arguments(config, filter_reg) disables it. I didn't specify anything admin related in either call yet they have opposite behaviors e.g I can't have run_server_with_arguments(config, filter_reg) and have admin enabled?
I think this would be clearer if we say admin is always disabled and to enable it pass in the builder explicitly so we avoid any combinatorial argument passing issues

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we have such nice defaults on the proxy::Builder I got rid of the various run_server functions, and kept just a single function that takes a proxy::Builder -- I think it makes things much neater overall. Have a look, let me know what you think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep the run_server(config) function? I think its simple api would be worth it to avoid having to duplicate Builder::from(Arc::new(server_config)).disable_admin() in every test case since it allows the most common scenario to be config free

Copy link
Member Author

@markmandel markmandel Mar 26, 2021

Choose a reason for hiding this comment

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

So run_server_with_config(config) and run_server_with_builder(builder) ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah that sounds reasonable to me!

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@markmandel markmandel merged commit b5e088f into main Mar 29, 2021
@markmandel markmandel deleted the feature/admin-server branch March 29, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes kind/cleanup Refactoring code, fixing up documentation, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make metric port configurable
2 participants